From code
Write test assertions as complete, strict deep-equality checks, and hold existing tests to the same standard. Use when writing new tests, adding assertions, reviewing test quality, strengthening weak tests, or replacing fragmented assertions in a file, directory, diff, or repository.
How this skill is triggered — by the user, by Claude, or both
Slash command
/code:test-assertionsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Write each assertion to capture a value's complete structure in one strict deep-equality check. Reach for one full-value assertion first rather than a cluster of narrow checks you consolidate later. Hold existing tests to the same standard when reviewing or strengthening them.
Write each assertion to capture a value's complete structure in one strict deep-equality check. Reach for one full-value assertion first rather than a cluster of narrow checks you consolidate later. Hold existing tests to the same standard when reviewing or strengthening them.
Do not change snapshots unless the user explicitly includes them.
Use the strictest deep-equality matcher the framework offers for objects, arrays, sets, maps, class instances, and other structured values (in Jest, toStrictEqual). Replace looser equality, partial matchers, property checks, containment checks, length checks, and existence guards when one complete assertion can express the expected value.
Use exact-equality for primitives (in Jest, toBe). Tighten calls and exceptions to their exact observable contract: the exact arguments, error type, and message.
Assert native collection types directly rather than converting them to arrays.
Do not infer an expected value from implementation code. When writing a new assertion or replacing a weak one, start with a deliberately incomplete strict assertion, run the narrowest relevant test, and use the failure output to capture the actual value. Then review that value as the intended contract and rerun the test.
expect(result).toStrictEqual({});
If the observed value reveals a bug or an unclear contract, stop and ask the user instead of blessing it as expected behavior.
Write one structural assertion instead of several narrow ones; collapse fragmented assertions in existing tests the same way:
expect(result).toStrictEqual({
id: 'order-100',
status: 'confirmed',
items: [
{sku: 'A-100', quantity: 2},
{sku: 'B-100', quantity: 1},
],
shipping: {method: 'express', estimatedDays: 3},
});
Do not retain redundant length, existence, or property assertions before a complete value assertion.
Prefer deterministic test data: freeze time, inject identifiers, and use fixed test paths. When a value genuinely comes from outside the test's control, assert that property separately, remove it from the value, and strictly assert everything remaining.
Do not turn type checks into booleans inside assertion objects; that hides the actual value in failures. For deterministic dates, assert the exact value, such as new Date("2000-01-01T00:00:00.000Z").
Extract expected values longer than about 50 lines into a clearly named constant or fixture.
Run the narrowest affected tests while discovering values, then run the repository's applicable test and precommit checks. Leave no placeholder assertions behind.
npx claudepluginhub motlin/claude-code-plugins --plugin codeGuides writing tests that pin real behavior instead of implementation details. Use when adding new tests, fixing flaky tests, reviewing test diffs, or after refactors.
Generic test writing discipline: test quality, real assertions, anti-patterns, and rationalization resistance. Use when writing tests, adding test coverage, or fixing failing tests for any language or framework. Complements language-specific skills.
Reviews test code for common maintenance issues like mock-heavy tests, duplicate bodies, and framework-verification. Supports pytest, Jest, Vitest, and PHPUnit.