test-guidelines
Skill1.8k starsChanged 3 months agoMITView on GitHub
Enforce Sentry React Native SDK test conventions for naming, structure, mocking, and fixtures with Jest. Use when writing tests, adding tests, modifying tests, reviewing test code, fixing failing tests, adding coverage, TDD, test-first / red-green, reproducing bugs with tests, regression tests, or test refactoring in `packages/core`.
1 other project uses a version of this.
Trending
Quiet this year.thin dataabout the whole repository
Most recently taken up by
- getsentry/sentry-darttheir own version, first seen Jul 1, 2026
Who's talking about getsentry/sentry-react-native
- bluesky-social/social-app“Make Sentry optional”GitHub · Sep 8, 2023 · 21 reactions
- expo/sentry-expo“Critical Security - Upgrade @sentry/react-native to 1.3.9”GitHub · May 21, 2020 · 15 reactions
- expo/expo“[SDK 51] Xcode 16 compilation fails on pegged Sentry version”GitHub · Jul 2, 2024 · 14 reactions
- react/react-native“[0.60.3] --sourcemap-output | enableHermes: false | gradle file | wrong output path”GitHub · Jul 17, 2019 · 10 reactions
- expo/expo“[expo] Bump recommended @sentry/react-native version”GitHub · Sep 25, 2024 · 8 reactions
The biggest 5 of 9 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 9
Talked about on GitHub (9 times).
On GitHub · 9
- Sep 8, 2023Make Sentry optional — bluesky-social/social-app21 reactions
- May 21, 2020Critical Security - Upgrade @sentry/react-native to 1.3.9 — expo/sentry-expo15 reactions · 28 comments
- Jul 2, 2024[SDK 51] Xcode 16 compilation fails on pegged Sentry version — expo/expo14 reactions · 12 comments
- Jul 17, 2019[0.60.3] --sourcemap-output | enableHermes: false | gradle file | wrong output path — react/react-native10 reactions · 8 comments
- Sep 25, 2024[expo] Bump recommended @sentry/react-native version — expo/expo8 reactions · 1 comment
4 more on GitHub
- Jul 19, 2024Update sessions after running beforeSend — getsentry/sentry-cocoa7 reactions · 6 comments
- Jun 22, 2022Bundling React Native with Hermes manually — react/react-native7 reactions · 24 comments
- Nov 6, 2019Implement hermes source maps — getsentry/rust-sourcemap7 reactions · 2 comments
- May 30, 2023Upgrade `@sentry/react-native` to version `5` — expo/sentry-expo6 reactions · 6 comments
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- getsentry/sentry-dart★ 873same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- packages/core/AGENTS.mdAGENTS.md
- packages/core/android/AGENTS.mdAGENTS.md
- packages/core/ios/AGENTS.mdAGENTS.md
- samples/expo/AGENTS.mdAGENTS.md
- samples/react-native/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- code-guidelinesSkill
- design-firstSkill
- diagnosing-bugsSkill
- reviewSkill
- specSkill
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 4 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Follow the convention in packages/core/AGENTS.md: describe/it blocks (preferred), with the it describing the expected behavior for a given …
- Very specific: line 30
Write it as a clear behavior description, e.g.
- Distinctive: line 61
Use specific matchers — they produce better failure messages:
- Very specific: line 75
Reset between tests: Use afterEach(() => { jest.clearAllMocks().
- Very specific: line 76
Mock the native module, not the whole SDK: Prefer the shared helpers (test/mockWrapper.ts, test/mocks/) over re-mocking react-native ad hoc.
- Very specific: line 85
Test both architectures / platforms: when the code branches on them.
- Very specific: line 86
Prefer injecting a fake at a seam over jest.mock of a deep import — a test that mocks internals breaks on refactors even when behavior is …
- Distinctive: line 87
Don't mock the thing under test.
- Very specific: line 91
Always await async assertions.
- Distinctive: line 93
No real network or filesystem.
- Distinctive: line 99
Every bug fix carries a regression test that goes red before the fix and green after.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Apply these conventions to all new and modified tests in packages/core. Existing tests may not follow them — do not refactor them unless asked. Tests run on Jest (yarn test, yarn test:watch, yarn test:sdk, yarn test:tools).
Tests are easiest to write against code designed to accept its dependencies — when implementing the code under test, load design-first (where the seams go) and code-guidelines (the rules).
Test-first loop
Work in vertical slices. One failing test → the minimal code that makes it pass → repeat. Each test proves one thin path end-to-end, and what it teaches shapes the next.
Do not write all the tests first and then all the implementation. That horizontal slicing produces tests of imagined behavior — they assert the shape you guessed at and pass when the real behavior breaks. Write one test at a time, against behavior you can already reason about.
Fixing a bug? Reproduce it with a failing test first — see diagnosing-bugs.
File structure
- One test file per source file. Mirror the path:
src/js/client.ts→test/client.test.ts;src/js/integrations/release.ts→test/integrations/release.test.ts. - React component tests use
.test.tsxand@testing-library/react-native. - A single top-level
describenaming the unit under test, with nesteddescribe/itinside it.
Naming
Follow the convention in packages/core/AGENTS.md: describe/it blocks (preferred), with the it describing the expected behavior for a given input.
- The top-level
describenames the unit under test — the exported name (myFeatureIntegration,NATIVE, the class). - Nested
describegroups a method or a scenario;itstates the behavior being verified. - Write
itas a clear behavior description, e.g.returns expected value when input is valid.
describe('nativeLinkedErrorsIntegration', () => {
describe('when the native module is unavailable', () => {
it('returns the event unchanged', () => { /* ... */ });
});
describe('processEvent', () => {
it('appends linked errors up to the configured limit', () => { /* ... */ });
});
});Style — Arrange / Act / Assert
Structure every test in three clear sections; a blank line between them is enough.
it('returns expected value when input is valid', () => {
// Arrange
const input = 'test';
// Act
const result = functionName(input);
// Assert
expect(result).toBe('expected');
});Use specific matchers — they produce better failure messages:
expect(array).toHaveLength(3); // not expect(array.length).toBe(3)
expect(obj).toMatchObject({ a: 1 }); // partial structural match
expect(fn).toThrow(Error);
await expect(promise).resolves.toBe('ok');
await expect(promise).rejects.toThrow();Assert the exact symptom, not "didn't crash". A test that only checks a call didn't throw catches almost nothing.
Mocking
- Reset between tests. Use
afterEach(() => { jest.clearAllMocks(); })(orresetAllMockswhen you also stub implementations). A leaked mock is the most common flaky-test cause here. - Mock the native module, not the whole SDK. Prefer the shared helpers (
test/mockWrapper.ts,test/mocks/) over re-mockingreact-nativead hoc. When you must, mock the bridge surface only:
jest.mock('react-native', () => ({
NativeModules: { RNSentry: { fetchNativeSdkInfo: jest.fn(() => Promise.resolve({})) } },
Platform: { OS: 'ios', select: (o: any) => o.ios ?? o.default },
}));- Test both architectures / platforms when the code branches on them. Drive
Platform.OS,isTurboModuleEnabled(),isFabricEnabled()from the test rather than assuming one. - Prefer injecting a fake at a seam over
jest.mockof a deep import — a test that mocks internals breaks on refactors even when behavior is unchanged (see design-first: the interface is the test surface). - Don't mock the thing under test. Don't assert on private internals; assert on observable output (the event, the envelope, the resolved value).
Async & timers
- Always
awaitasync assertions; return or await the promise so Jest sees failures. - For timing-dependent code (flush timers, debounces, retries) use fake timers (
jest.useFakeTimers()+jest.advanceTimersByTime(...)), not realsetTimeout— real delays make tests slow and flaky. Restore withjest.useRealTimers()inafterEach. - No real network or filesystem. Stub the transport / bridge.
What to test
- The behavior at the seam a caller depends on — inputs → observable outputs.
- Edge cases the code guidelines call out: native module missing,
enableNativefalse, PII gating on/off, serialization round-trips across the bridge, both architectures. - Every bug fix carries a regression test that goes red before the fix and green after.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

