/eng:testingfrom Engineering Skills
House testing standard for Vitest across Next.js apps, an API, shared packages and workers — test levels and what each catches, async Server Components, mock only the I/O boundaries, in-memory fakes over call recorders, typed manual mocks, shared fixtures, route specs with a real Request, emulator and browser runs, deterministic and independent tests, flaky tests, coverage, and never weakening a failing test. Use when writing, fixing or reviewing tests, or setting up Vitest in a workspace.
Ships in Engineering Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Tests mock only what they can't run — the network, the cloud SDKs, the framework's request APIs, timers — and run the real workspace code everywhere else, so a passing suite means the pieces actually fit. A test describes behaviour; a red test means the code under test is wrong until shown otherwise.
Before applying this skill, read the project's root AGENTS.md, the AGENTS.md closest to the files in question, and any doc they link for this skill's topic. Names, values and choices — budgets, tiers, tokens, voice, paths — come from those files, never from this skill.
| Level | Runs | Catches |
|---|---|---|
| Unit | a function, hook or component alone, I/O mocked | logic and edge cases, in milliseconds |
| Integration | a route, action or service through the real layers, against fakes or the store's emulator | the pieces fitting: validation, guards, writes, audit |
| End-to-end | the built app in a browser (Playwright) | journeys, async Server Components, what only a page proves |
Most tests are unit and integration; end-to-end covers the few journeys the product can't break (sign-in, checkout) and what nothing else can reach.
next/navigation, next/headers, next/cache, server-only, fetch, timers, a hosted Redis client. These are the I/O edges.Prefer an in-memory fake to a call recorder. A Firestore or Storage fake that behaves like the store lets a spec assert on what was written, not on how it was called, so a refactor that writes the same data a different way still passes.
A manual mock lives in <workspace>/__mocks__/<package>/…, each export a vi.fn() typed with the SDK's own signature, so vi.mocked(...) is checked against the real API and a drifted mock fails the type check instead of passing silently:
// firebase-auth.mock.ts
import type * as FirebaseAuth from "firebase/auth";
import { vi, type Mock } from "vitest";
export const onIdTokenChanged: Mock<typeof FirebaseAuth.onIdTokenChanged> = vi.fn();
Fixtures and fakes live in src/testing/, named for their export (user.fixture.ts with buildUser, firebase-auth.fake.ts). The suffixes are naming's.
A fake or mock two workspaces use moves into a shared testing package on its second consumer, and each workspace's __mocks__ file re-exports it — Vitest reads a manual mock only from the workspace's own folder. Two copies drift, and a fix lands in only one.
Colocate the spec beside the file it tests (event.action.test.ts, route.test.ts), so a missing test is visible in the tree.
Cover the behaviour in full: the success path, each refusal and each edge. A test written only to go green proves nothing.
A route spec calls the exported handler with a real Request, against the in-memory fakes swapped in for the project's client module, and asserts on the response, the stored data and any audit entry:
vi.mock("@/server/clients/firebase/client", async () => {
const { fakeFirestore } = await import("@org/testing/firestore");
return { firestore: fakeFirestore };
});
it("suspends the user and audits the reason", async () => {
const response = await POST(buildBearerRequest(`/api/v1/admin/users/user-1/suspend`, "token", { method: "POST", body: { reason: "Spam" } }), {
params: Promise.resolve({ uid: "user-1" }),
});
expect(response.status).toBe(200);
expect(readUser("user-1")).toMatchObject({ isSuspended: true });
});
A hook or component spec renders through the same providers the app uses (a session wrapper, the router store), with the SDK mocked and programmed in beforeEach. A form submits through the real form library, so the real schema runs.
Names in tests follow naming — a helper called data is as unclear in a spec as anywhere else.
vi.resetAllMocks() after each test, and each spec re-applies its implementations in beforeEach. One test's mockResolvedValue must never become the next test's default.server-only.vi.setSystemTime, never the real clock; the timezone is fixed (TZ=UTC in the test env) and so is the locale, so a date or number formats the same on every machine; random fixture data comes from a seeded generator whose seed is printed on failure.sequence.shuffle) at least in CI, so one that leans on another's leftovers fails where it can be seen.test.server.deps.inline). Loaded untouched from node_modules, it gets the real module underneath your mock.lib/ and route handlers run in node and hooks and components in jsdom.@firebase/rules-unit-testing). The emulator runs any valid query without its composite index, so indexes are checked separately (firestore).turbo run test --concurrency=2). Each suite starts its own worker pool, and more at once oversubscribes a laptop or a CI runner, so tests time out for lack of a core rather than a bug. A suite that's still slow under load raises its own timeout.vitest --sequence.shuffle --repeats 20), then fix the leaked state, the real clock or the race behind it. End-to-end tests may retry in CI, with every retry reported.play function and fails on an accessibility violation. How is storybook's.devops'.expectTypeOf in a *.test-d.ts, with Vitest's typecheck on) for shared generic helpers and the contracts' inferred types, where a wrong type is the bug.openapi-registry).Never delete, skip or weaken a failing assertion to make a suite pass. A red test means the code under test is wrong until shown otherwise: fix the code. If the test itself is wrong — it asserts behaviour the spec no longer wants — change it on purpose and say why in the commit.
node_modules. Inline that dependency.naming; where src/testing/ and the testing package sit → code-structure.storybook.devops.codebase-audit.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub timonwa/engineering-skills --plugin eng20 skills in this plugin
/agents-mdWrites or updates a project's AGENTS.md and the short AGENTS.md notes in each app and package — what an agent can't work out from the code: commands, structure, conventions that differ from the defaults, workflow, recorded deviations from the house standards and hard constraints, under 200 lines. Use when starting a project, setting up AGENTS.md or CLAUDE.md, or bringing a project's agent instructions up to date./audit-allManually invoked. Runs the house audit suite across the eng, fe and be sets — detects what the repo has, runs every installed audit that applies (codebase, conventions, dependencies, env, security, accessibility, frontend, performance, SEO/AEO/GEO, Storybook, content, API, access control, Firestore, Redis), and rolls their reports into one health report with an overall score and cross-cutting priorities. Each audit still writes its own report./Other plugins' skills for the same job