This skill guides you to enforce consistent test file conventions, setup patterns, and clear naming in TypeScript test suites.
npx playbooks add skill epicenterhq/epicenter --skill testing
Keep tests that help us catch mistakes that matter. Improve or delete tests that give false reassurance or create work without protecting behavior we care about.
Ask what important mistake could happen, whether the test would actually
catch it, and whether the behavior could be protected more simply. Trace the
production path, the setup that makes the failure possible, and the assertion
that detects it. Apply this scrutiny to tests you write as well as existing
ones, including AI-generated tests. Check what a passing result establishes;
test counts and coverage percentages do not establish confidence.
Look for tests, assertions, fixtures, and production seams that add no useful
protection. Combine or delete redundant checks, remove tests for retired
behavior, and repair or replace tests whose setup excludes the failure they
claim to cover. Different inputs, failure mechanisms, dependency boundaries,
and faster diagnosis can justify separate tests. Read unfamiliar tests and
their relevant history before deciding that they have no useful job.
Choose production structure and test boundaries together. When testing
motivates a helper, export, or injected dependency, ask: without the test,
would I have written this as two pieces? Keep boundaries that explain a
responsibility, own a lifecycle, or isolate an external dependency. Test-only
substitution can also earn its place by making important failures reproducible.
Caller counts and line counts are clues, not verdicts.
Before removing a test that detects a required regression, identify what still
catches it. If you can't name where the coverage goes, you haven't earned the
deletion. A test that never detected the claimed failure has no such coverage
to relocate; establish whether the behavior needs a better test. Keep or delete
based on what the test actually contributes, not whether it is currently green
or red. Investigate a failure before changing the expectation or removing it.
Read [the worked examples](references/choosing-useful-tests.md) for examples of
misleading coverage, redundant checks, and useful test seams. Use
[the test deletion grill](references/test-deletion-grill.md) when investigating
whether tests, shared setup, or production seams still earn their cost.
Load these on demand based on what you're working on:
expectTypeOf, @ts-expect-error, compiler checks, intentional runtime-invalid input), read [references/type-testing.md](references/type-testing.md)setup() patterns, composable setup, cleanup hooks, shared schemas), read [references/setup-pattern.md](references/setup-pattern.md)describe() boundaries, helper-over-nesting), read [references/test-structure.md](references/test-structure.md)External reading:
expectTypeOf import hereshoehorn](https://github.com/total-typescript/shoehorn) : partial fixtures for legacy or third-party interfaces; incomplete fixtures do not prove a complete input contract> Related Skills: See [typescript](../typescript/SKILL.md) for API design, inference, and editor behavior.
When a test asserts a wellcrafted Result, use expectOk and expectErr
from wellcrafted/testing instead of hand-rolled error checks.
import { expectErr, expectOk } from 'wellcrafted/testing';
const data = expectOk(await service.doThing());
expect(data.id).toBe('1');
const error = expectErr(await service.doThing({ invalid: true }));
expect(error.name).toBe('InvalidInput');
Avoid local helper clones, expect(error).toBeNull() success checks, andif (error) throw ... unwrapping when the value is a wellcrafted Result.
This rule does not apply to plain response bodies, UI snapshots, or other
objects that merely have an error property.
Two distinct file extensions, two distinct purposes:
.test.ts* : verifies behavior or type contracts. Runtime tests rununder bun test and may use expect() or assertion helpers. Compiler-only
tests such as *.types.test.ts need no runtime assertion; include them in
the package's typecheck. Passing runtime tests do not verify type assertions.
.bench.ts* : measures and reports. Prints tables, timings, orstorage sizes. Run it directly with bun <file>; no root script runs benchmarks. No assertions required
(perf thresholds on shared hardware flake; prefer visual trends).
A single file is one or the other, never both. Benchmarks live undersrc/__benchmarks__/ within a package; tests are colocated with the module
they cover. The bun test default-discovery glob picks up only *.test.ts
and friends, so renaming a report from .test.ts → .bench.ts is what
excludes it from CI.
Every .test.ts file MUST start with a JSDoc block explaining what is being tested and the key behaviors verified. This serves as documentation for the module's contract.
/**
* [Module Name] Tests
*
* [1-3 sentences explaining what this file tests and why these tests matter.]
*
* Key behaviors:
* - [Behavior 1]
* - [Behavior 2]
* - [Behavior 3]
*
* See also:
* - `related-file.test.ts` for [related aspect]
*/
/**
* Cell-Level LWW CRDT Sync Tests
*
* Verifies cell-level LWW conflict resolution where each field
* has its own timestamp. Unlike row-level LWW, concurrent edits to
* DIFFERENT fields merge independently.
*
* Key behaviors:
* - Concurrent edits to SAME field: latest timestamp wins
* - Concurrent edits to DIFFERENT fields: BOTH preserved (merge)
* - Delete removes all cells for a row
*/
// Tests for create-tables
For long test files (100+ lines), use comment headers to separate logical sections:
// ============================================================================
// MESSAGE_SYNC Tests
// ============================================================================
When a module has distinct behavioral aspects, split into focused test files rather than one monolithic file:
| Pattern | Use Case |
| ----------------------------- | ---------------------------------------------------- |
| {module}.test.ts | Core CRUD behavior, happy paths, edge cases |
| {module}.types.test.ts | Type inference verification, negative type tests |
| {module}.{scenario}.test.ts | Specific scenarios (CRDT sync, offline, integration) |
Test descriptions MUST be behavior assertions, not vague descriptions. The name should tell you what broke when the test fails.
test('upsert stores row and get retrieves it', () => { ... });
test('filter returns only published posts', () => { ... });
test('concurrent edits to different fields: both preserved', () => { ... });
test('delete vs update race: update wins (rightmost entry)', () => { ... });
test('observer fires once per transaction, not per operation', () => { ... });
test('get() throws for undefined tables with helpful message', () => { ... });
test('should work correctly', () => { ... }); // What works? What's correct?
test('should handle batch operations', () => { ... }); // Handle how?
test('basic test', () => { ... }); // Says nothing
test('should create and retrieve rows correctly', () => { ... }); // Vague "correctly"
{action} {outcome} [condition]"upsert stores row and get retrieves it"
^^^^^^ ^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^
action outcome action outcome
"observer fires once per transaction, not per operation"
^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
subject outcome condition
"get() returns not_found for non-existent rows"
^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
action outcome conditionWeekly roundup of top Claude Code skills, MCP servers, and AI coding tips.