agentleFS
VercelKnown publishervercel/next.js/.agents/skills/run-tests/SKILL.md

run-tests

Skill144k starsChanged 7 months agoMITView on GitHub

Run Next.js tests reliably in a fresh checkout or worktree, and reproduce or fix flaky tests. Use for Playwright browser install errors, missing build outputs, pnpm test-unit or Jest selection surprises, run-tests.js repeats, CI env flags for snapshot tests, native binding selection, ignored fixture files such as tsconfig.json, CI-only test type/lint gates, CPU-starved flakes, fixed waits, requestIdleCallback starvation, or flake-detection failures.

  • Installs packages

17 other projects use a version of this.

Trending

Less talk lately.about the whole repository

Jan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 3 mentionsApr 2026: 2 mentionsMay 2026: 4 mentionsJun 2026: 4 mentionsJul 2026: 3 mentionsAug 2026: 2 mentionsSep 2026: 3 mentionsOct 2026: 3 mentionsNov 2026: 1 mentionDec 2026: 0 mentions
Jan 2026Jul 2026Dec 2026
Mentions a month of the vercel/next.js repository that our weekly crawl found. There is no adoption data for this file yet.

Most recently taken up by

Who's talking about vercel/next.js

The biggest 5 of 92 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 92

Talked about on Bluesky, GitHub and Hacker News (92 times).

On Bluesky · 50

45 more on Bluesky

On GitHub · 26

21 more on GitHub

On Hacker News · 16

11 more on Hacker News

Used with

Projects with it also use code-review.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • GoogleSkill

    code-review

    Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 17 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this skill when running, adding, or debugging tests in the Next.js repo.

    line 17
  2. Very specific:

    Run pnpm install --frozen-lockfile.

    line 23
  3. Very specific:

    Before pushing, compare the tracked fixture files with the files the test needs.

    line 98
  4. Very specific:

    When test files change, run pnpm lint-typescript (or the full pnpm types-and-precompiled when its clean-tree check is appropriate).

    line 105
  5. Distinctive:

    Treat unexpected snapshot churn as a possible regression.

    line 113

“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Run Tests

Use this skill when running, adding, or debugging tests in the Next.js repo. The basic commands are in the root AGENTS.md. For flaky tests, read flaky-tests.md.

Bootstrap a fresh checkout

  1. Run pnpm install --frozen-lockfile. If you are deliberately building native bindings from source and the native postinstall fails, use NEXT_SKIP_NATIVE_POSTINSTALL=1 (see scripts/install-native.mjs).
  2. Build JS with workspace dependencies: pnpm build. In a fresh checkout, a bare pnpm --filter=next build can miss workspace outputs such as polyfills.
  3. Install the browser version that matches the repo's Playwright: pnpm exec playwright install chromium. A different Chromium can still fail with Executable doesn't exist.
  4. Rust or Turbopack changes need a native build before Next.js e2e tests. See the root AGENTS.md rebuild rules.

Choose the command

  • Mode-specific scripts such as pnpm test-dev-turbo call scripts/run-jest.sh and set the mode and bundler.
  • A dev-only test can be skipped by test-start-*. Check isNextDev, gates, and the CI job before choosing a command.
  • pnpm test-unit <file> appends <file> to jest test/unit/ packages/next/ packages/font, so it can run all of those suites. Use pnpm exec jest <file> for one file.
  • Jest only searches the roots in jest.config.js. A copied test outside those roots reports No tests found. Use a temporary worktree for experiments.
  • node run-tests.js is the CI runner:
    • --retries 0 --runs N repeats each selected file; repeats require --retries 0 and fail when NEXT_SKIP_ISOLATE is set.
    • --concurrency 1 serializes files.
    • --debug shows test output.
    • It selects files, not individual test names. Use a Jest script with -t to focus one case.

Match CI

  • Inline snapshots can depend on CI env flags. Use the exact afterBuild: flags from .github/workflows/build_and_test.yml, keep them set for the full run, and use the same bundler. For example build-output-prerender expects __NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true. The react-dom/server build depends on runtime and bundler: Edge contexts get server.edge (no renderToPipeableStream), Node contexts get server.node, and the Pages renderer differs between bundlers. Check crates/next-core/src/next_import_map.rs (Turbopack) and packages/next/src/build/create-compiler-aliases.ts (webpack).
  • For exact replication of a failed job, use $pr-status-triage and its local-repro.md.
  • Isolated installs use a .node file from packages/next-swc/native when present; otherwise they use the installed @next/swc-* package. Check the logged swcNativeDirectory before trusting a native-binding repro.
  • nextTestSetup({ dependencies }) installs dependencies in the isolated app. A require() in the Jest test file still resolves from the repo. Run isolated tools as child processes with their cwd in the test app.
  • New test/e2e suites also run in deploy mode. Read test/AGENTS.md before adding file patches or log assertions.

Quick smoke testing

For fast feedback, generate a fixture with pnpm new-test --args true <name> e2e. Run Next.js with the fixture as the working directory and an absolute path to the built CLI:

cd <fixture-dir>
node <repo>/packages/next/dist/bin/next dev --port <port>

Probe it with curl --max-time 10. If a throwaway app symlinks packages from the checkout, link next, react, and react-dom individually. Set turbopack.root and outputFileTracingRoot to a common parent when the build needs to resolve the linked next package.

Commit fixtures completely

  • test/.gitignore ignores tsconfig.json under e2e/**, production/**, and development/**. If the fixture needs that file, force-add it with git add -f. Don't force-add generated next-env.d.ts.
  • The root .gitignore only ignores the Rust target directories of the Cargo workspaces. If you add a Cargo workspace, add its target path there.
  • Before pushing, compare the tracked fixture files with the files the test needs. Use git ls-tree -r --name-only HEAD -- <dir>, or git check-ignore -v <path> for a single path.

Gates beyond the test run

  • pnpm --filter=next types uses tsconfig.build.json, which excludes tests. When test files change, run pnpm lint-typescript (or the full pnpm types-and-precompiled when its clean-tree check is appropriate).
  • pnpm lint-language runs alex on Markdown files. After editing docs, run pnpm exec alex <files> --quiet.
  • CI checks the PR merged with current canary. If Prettier passes locally but fails in CI, compare .prettierignore and the formatter config with canary.
  • Common test-file ESLint rules include jest/no-standalone-expect and @typescript-eslint/prefer-as-const.
  • Treat unexpected snapshot churn as a possible regression. Find the source of the output change before updating snapshots.

Related Skills

  • $pr-status-triage - CI failure triage and exact CI env reproduction
  • $gate-tests - @gate / @force-gate instead of skips
  • $router-act - deterministic client-router tests

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.