← ClaudeAtlas

testing-disciplinelisted

Testing discipline for TypeScript test files — reproduce regressions first, test observable behavior and typed failures, keep doubles at owned boundaries, and preserve unexpected rejections.
g-bastianelli/nuthouse · ★ 1 · Testing & QA · score 65
Install: claude install-skill g-bastianelli/nuthouse
# subroutine — testing discipline Apply this to TypeScript tests. The nearest `AGENTS.md` decides the runner, allowed layers, and React test policy. ## Prove behavior - For a bug, write the smallest regression test and see it fail before the fix. Name the behavior, not the implementation. - Assert public outputs, effects, events, or typed errors. Avoid private tests, incidental call counts, and broad snapshots. - Cover success, every expected `Result` variant introduced by the change, and unexpected rejection when propagation is part of the contract. ```ts test("returns CONFLICT for a duplicate reference", async () => { store.insert.mockRejectedValue(uniqueViolation); await expect(createOrder({ input, store })).resolves.toEqual( err({ code: "CONFLICT", reason: "duplicate-reference" }), ); }); test("preserves an unexpected database outage", async () => { store.insert.mockRejectedValue(outage); await expect(createOrder({ input, store })).rejects.toBe(outage); }); ``` ## Keep tests trustworthy - Inject time, IDs, randomness, and clients only when behavior depends on them. Fake an owned port; never mock a query builder or private call chain. - Keep fixtures minimal and explicit. A fixture default must not hide the field the test is meant to exercise. - Unit-test deterministic logic; integration-test real serialization, database, or transport boundaries. Do not simulate integration with a forest of mocks. - Never add `.test.tsx`, DOM tooling, or co