← ClaudeAtlas

write-testslisted

Writes Jest unit tests the house way in a React Native repo. Use when the user asks to add or write tests, says "test this", or after changing merge logic, persist transforms, sync, eligibility rules, verification, ordering, or utility logic. Covers detecting the repo's unit Jest config, what its setup file mocks, the fixture-builder test style, how to run one focused file, and what does or does not deserve a test.
ltatarev/skills · ★ 0 · Testing & QA · score 65
Install: claude install-skill ltatarev/skills
# Writing unit tests Unit tests in these projects are **pure-logic tests**: node environment, a minimal mocked `react-native`, no renderer. The standard: test non-trivial business logic (merge, persist, sync, eligibility, verification, ordering, edge-case utils) with small fixture builders; never write trivial assertion-only tests. ## Step 1 — read the repo's test setup before writing anything Never assume the config. These repos commonly have **two** Jest configs and only one of them is the real unit-test path. 1. Read `package.json` scripts. Look for a dedicated unit script (often `test:unit`) pointing at its own config (often `jest.unit.config.js`). A bare `test` script using the `react-native` preset is usually *not* where the tests live — check which config the existing tests actually match. 2. Read that config and note: - `testEnvironment` — typically `node`, meaning no jsdom and no native runtime. - **`testMatch`** — this is the trap. If it is `['**/*.test.ts']`, a `.test.tsx` file is **silently skipped**. Component/JSX tests are then not supported at all, and naming a file `.test.tsx` ships an unrun test that looks green. - `setupFiles` — read the setup file and list what it mocks globally. 3. Read 2–3 existing test files near the code you are testing. Mirror their imports, fixture style, and naming exactly. A typical setup file globally mocks: `__DEV__ = false`; `react-native` down to just `{ NativeModules: {}, Platform }` wit