agentleFS
VercelKnown publishervercel/next.js/test/AGENTS.md

next.js / test

AGENTS.md144k starsChanged 7 months agoMITView on GitHub

Tests for behavior that affects deployed applications must live in test/e2e/ and exercise the real deployment path. This applies to new features and regressions. Reserve test/production/ for behavior inherently specific to self-hosted servers or the local CLI. Simulating minimal mode is an exception. Use private switches such as NEXT_PRIVATE_MINIMAL_MODE and NEXT_PRIVATE_TEST_HEADERS only when a real deployment cannot exercise the protocol invariant under test. Explain that constraint in the test. A simulation must not replace real deployment coverage of behavior that…

Trending

Less talk lately.about the whole repository

Dec 2025: 4 mentionsJan 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 mention
Dec 2025Jun 2026Nov 2026
Mentions a month of the vercel/next.js repository that our weekly crawl found. There is no adoption data for this file yet.

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

The file

We split this AGENTS.md into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    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. Distinctive:

    Use the deployment log support first:

    line 17
  2. Distinctive:

    Keep response status, body, and other deployment-compatible assertions active.

    line 28
  3. Distinctive:

    All newly created e2e tests must work with Cache Components both enabled and disabled.

    line 32
  4. Very specific:

    Write fixtures that conform to Cache Components rules by default: put uncached or request-time work behind appropriate <Suspense> …

    line 37
  5. Very specific:

    Do not pin cacheComponents: false or skip the enabled variant just to make an otherwise compatible test pass.

    line 41
  6. Distinctive:

    Only exclude the Cache Components variant when the feature under test is explicitly unsupported, such as Edge Runtime or another …

    line 45
  7. Very specific:

    Always use LinkAccordion to control when prefetches happen inside act scopes.

    line 76
  8. Very specific:

    Cache Components enables PPR by default: When __NEXT_CACHE_COMPONENTS=true, most app-dir pages use PPR implicitly.

    line 83

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “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
AGENTS.md

Test instructions

Deployment coverage

Tests for behavior that affects deployed applications must live in test/e2e/ and exercise the real deployment path. This applies to new features and regressions. Reserve test/production/ for behavior inherently specific to self-hosted servers or the local CLI.

Simulating minimal mode is an exception. Use private switches such as NEXT_PRIVATE_MINIMAL_MODE and NEXT_PRIVATE_TEST_HEADERS only when a real deployment cannot exercise the protocol invariant under test. Explain that constraint in the test. A simulation must not replace real deployment coverage of behavior that deployed applications can observe.

Log assertions do not justify excluding a whole test or suite from deploy mode. Use the deployment log support first:

  • next.cliOutput exposes deployment build logs, including failed-build diagnostics.
  • NextDeployInstance.getRuntimeLogs({ since, query, deadline }) reads runtime logs for deployments made or inspected through the Vercel CLI. Poll with retry() because runtime logs become available with a delay.

The runtime log helper is unavailable for custom deploy scripts. Custom deploy scripts provide build logs through NEXT_TEST_DEPLOY_LOGS_SCRIPT_PATH. If a deployment cannot provide a particular diagnostic, gate only that assertion. Keep response status, body, and other deployment-compatible assertions active.

Cache Components compatibility

All newly created e2e tests must work with Cache Components both enabled and disabled. The test infrastructure runs both variants. In the enabled variant, __NEXT_CACHE_COMPONENTS=true enables Cache Components even when the fixture's next.config does not declare cacheComponents.

  • Write fixtures that conform to Cache Components rules by default: put uncached or request-time work behind appropriate <Suspense> boundaries, and use "use cache" for work that should be cached. Preserve what the test is intended to cover when adapting the fixture.
  • Do not pin cacheComponents: false or skip the enabled variant just to make an otherwise compatible test pass. If behavior legitimately differs, keep meaningful assertions in both variants; use the resolved-config runtime gate() helper rather than checking environment variables.
  • Only exclude the Cache Components variant when the feature under test is explicitly unsupported, such as Edge Runtime or another incompatible feature. Explain the incompatibility in a comment and use a test gate. For a fixture that cannot build or run with Cache Components, put the gate directly above the suite's describe:

    // Edge Runtime is not supported with Cache Components.
    // @force-gate !cacheComponents
    describe('edge runtime', () => {
      // ...
    })

    @force-gate skips the incompatible variant; @gate instead runs the test with an expected failure and detects stale gates. The cacheComponents condition reads the fixture's resolved config, not just the environment. See the gate reference and $gate-tests for directive selection, build-skipping limitations, and verification guidance.

Client router tests

Tests of client navigations, prefetching, and router caches must trigger requests through the client router. Use createRouterAct and LinkAccordion to control and assert on those requests. Do not synthesize prefetch requests with next.fetch() and internal RSC or router headers, or call fetch() in the browser as a substitute. Let the router produce the request headers, router state, and prefetch stage. Ordinary HTTP requests are appropriate for fixture setup, such as revalidation. See the router-act skill for the patterns.

Always use LinkAccordion to control when prefetches happen inside act scopes. Never use browser.back() to return to a page where accordion links are already visible. BFCache restores state and triggers uncontrolled re-prefetches.

Test gotchas

  • Cache Components enables PPR by default. When __NEXT_CACHE_COMPONENTS=true, most app-dir pages use PPR implicitly. The dedicated ppr-full/ and ppr/ suites are mostly describe.skip while they migrate to Cache Components. To test PPR code paths, run normal app-dir e2e tests with __NEXT_CACHE_COMPONENTS=true.
  • Mode-specific tests need skipStart: true and a manual next.start() in beforeAll after the mode check.
  • Don't rely on exact log messages. Filter by content patterns, and find sequences rather than positions.
  • Show full stack traces with __NEXT_SHOW_IGNORE_LISTED=true. By default the dev server collapses internal frames to at ignore-listed frames, which hides framework internals. See packages/next/src/server/patch-error-inspect.ts.
  • For bootstrapping, CI env flags, smoke tests, flaky tests and ignored fixture files, use $run-tests.

Code review

  • During code review, enforce the deployment coverage rules above. Flag new test/production/ tests for deployable behavior, simulated minimal-mode setups, skipDeployment: true, and isNextDeploy exclusions. Require a concrete reason for each exception and keep deployment-compatible assertions active.
  • During code review, flag any new hardcoded cache tag or any revalidatePath('/') (including ('/', 'layout')) in a deploy-active fixture. Revalidation invalidates at Vercel project scope and every deploy suite shares one project per matrix dimension, so suites using the same tag or path purge each other's cache. Tags (cacheTag/revalidateTag/updateTag/next.tags) get a suite-slug prefix, e.g. app-static:thankyounext. Paths must name a real route, so a fixture that needs to revalidate / moves its page to a suite-unique route first (see parallel-routes-revalidation's /prr). A revalidation route handler that takes the tag/path from a request parameter is fine as long as the values the tests pass are suite-unique.
  • During code review, flag any fetch URL a fixture shares with another fixture when a test depends on the cached value. Fetch cache entries are keyed by URL across deployments, so two fixtures fetching the same URL share one entry, and either fixture's writes or revalidations change the value the other sees. Give the data endpoint suite-unique query params, e.g. api/random?app-static-page instead of api/random?page.

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.