new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Next.js · API reference · all subjects

testing

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Non-interactive test generation for AI agents

Generate tests non-interactively using: pnpm new-test --args <appDir> <name> <type>. Format parameters: appDir is true/false for app directory, name is test name (e.g. 'my-feature'), type is e2e | production | development | unit. Example: pnpm new-test --args true my-feature e2e

Use retry() instead of setTimeout for test waiting

Use retry() from next-test-utils for polling/waiting in tests, not setTimeout. Good pattern: import { retry } from 'next-test-utils'; await retry(async () => { const text = await browser.elementByCss('p').text(); expect(text).toBe('expected value') }). Bad pattern: await new Promise((resolve) => setTimeout(resolve, 1000))

Use retry() with expect() instead of deprecated check()

Do not use check() which is deprecated. Use retry() with expect() instead. Bad: await check(() => browser.elementByCss('p').text(), /expected/). Good: await retry(async () => { const text = await browser.elementByCss('p').text(); expect(text).toMatch(/expected/) })

Prefer real fixture directories over inline files objects in tests

Use real directory with fixture files for test setup instead of inline file definitions. Good: const { next } = nextTestSetup({ files: __dirname }) which points to directory containing test fixtures. Avoid: inline file definitions like const { next } = nextTestSetup({ files: { 'app/page.tsx': `...` } }) because they are harder to maintain.

Quick smoke testing with toy apps

For fast feedback, generate a minimal test fixture with pnpm new-test --args true <name> e2e, then run the dev server directly with node packages/next/dist/bin/next dev --port <port> and curl --max-time 10. This avoids the overhead of the full test harness and gives immediate feedback on hangs/crashes.

Rebuild requirements before running tests

When running Next.js integration tests, rebuild if source files have changed. First run after branch switch/bootstrap (or if unsure): pnpm build-all. Edited only core Next.js files (packages/next/**) after bootstrap: pnpm --filter=next build. Edited Next.js code or Turbopack (Rust): pnpm build-all.

Mode-specific tests require skipStart and manual next.start()

Mode-specific tests need skipStart: true plus manual next.start() in beforeAll after mode check to properly initialize in the correct mode.

Give your agent this brain