rule
running tests
How to run tests, check for failures, and rerun specific failing tests — use the :agent variants of slow commands
Set up
Skills are installed by placing their folder where your agent loads skills.
Part of the collection prisma/prisma-next.
Copy the text of running-tests.mdc into the instructions file your agent reads (CLAUDE.md, AGENTS.md, .cursor/rules, …). Written for AI coding agents in general (from where the project keeps it; we have not run it).
README
synced Oct 14, 2026How to run tests, check for failures, and get specific failures
1. Run a test suite
Each slow command has an :agent variant. The first line of its output prints the exact log path:
$ pnpm test:packages:agent
log: wip/test-packages.20260615-190441.32317.log
The full output goes to that file. The exit code is written to a sibling .exit file (same path with .log → .exit). Use the path printed by the command — don't guess one. Every run gets its own timestamped path, so history is preserved automatically. Contents of wip/ are gitignored.
Each :agent run has a hard timeout (default 5 minutes, override with AGENT_CMD_TIMEOUT_SECONDS — bump it for a legitimately long suite). If the run hangs — e.g. vitest freezes after printing its summary — the child process group is killed and the .exit file records 124 rather than blocking forever.
| Command | Purpose |
|---|---|
pnpm test:packages:agent | Unit tests for every package |
pnpm test:integration:agent | Integration suite (PGlite + mongodb-memory-server) |
pnpm test:e2e:agent | End-to-end suite |
pnpm build:agent | Build every package (turbo) |
pnpm typecheck:agent | Typecheck every package (turbo, cached) |
pnpm lint:agent | Biome lint |
pnpm lint:deps:agent | Dependency-layering check |
pnpm fixtures:check:agent | Regenerate fixtures and diff them |
2. Run one package's tests
pnpm --filter @prisma-next/cli test
Runs only that package's own test script — seconds, not minutes. Output goes to your terminal; no capture needed.
3. Rerun a specific failing test
By file:
pnpm --filter @prisma-next/cli test test/commands/migration-list-json-golden.test.ts
By test name within a file (vitest's -t filter):
pnpm --filter @prisma-next/cli test test/commands/migration-list-json-golden.test.ts -t "pins head ref decoration"
4. Find specific failures in the captured output
Use the log path the :agent command printed (the shell exit status tells you pass/fail; the .exit sibling file records the same number). If non-zero, list failing files and assertions:
grep -nE " FAIL |Test Files" wip/test-packages.20260615-190441.32317.log
grep -B2 -A20 "FAIL " wip/test-packages.20260615-190441.32317.log
If exit is non-zero but the log has no FAIL lines, the suite crashed before any test ran — read the tail:
tail -50 wip/test-packages.20260615-190441.32317.log
Don't
- Don't run the full suite when you already know which file is failing. Use the targeted commands in §3 — they run in seconds.
- Don't run the bare canonical commands (
pnpm test:packages, etc.) for a full-suite run. They dump the entire output into your context window. Use the:agentvariant. - Don't pipe a
:agentcommand totail/grep/head. The point is that the output is already on disk — read the log path the:agentcommand printed. - Don't re-run a suite to refine a grep. Grep the file you already have.
- Don't pass
--forcetoturbo. The cache is correct by default. Only force when this same run editedtsconfig.jsonor a lockfile.