write-testslisted
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