Index of every page on this site: llms.txt
All skills
vercel avatar

/run-tests

@7c179aa official
by vercelvercel/next.js144k stars
32,736
Run it yourself

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.

  • 2 files
  • 8.6 KB
  • Updated yesterday
  • GitHub
Use this Skill: https://skilld.dev/gh/vercel/next.js/run-tests

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈116 tokens for metadata: the name and description. ≈1.3k when used: this file. ≈768 more on demand in 1 file.

Description uses 5.8% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈465 characters, or 5.8%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

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

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 7c179aa. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated yesterday
metadata
{
  "internal": true
}

README badge

README badge for vercel/next.js/run-tests