AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Next.Js Testmode Playwright DefineConfig Forces Default Projects And Ignores User Overrides

The `defineConfig` wrapper from `next/experimental/testmode/playwright` always merges the built-in default browser projects (chromium, firefox, webkit) with any user-defined `projects`, preventing users from overriding the project list. This causes unwanted browser projects to run and may fail if those browsers are not installed.

highConfidence 88%Next.jsAffected V16.2.12

Origin Analysis

The Next.js `defineConfig` implementation concatenates the default `projects` array with the user-provided `projects` array instead of allowing the user array to replace the defaults when present.
1. Create a Next.js app and configure `playwright.config.ts` using `defineConfig` from `next/experimental/testmode/playwright` with `projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }]`.\n2. Install only Chromium via `npx playwright install chromium --with-deps`.\n3. Run `npx playwright test`.\n4. Observe that 4 projects are executed: `chromium`, `firefox`, `webkit` (from defaults) plus `chromium` (from user config), and tests fail on `firefox` and `webkit` with browser not found.

Fixing Code Block

Edge Case Audit

Existing users who relied on the previous concatenation behavior to run default browsers alongside their custom projects will lose the default projects after this fix. If such behavior is desired, they must explicitly include the default browser projects in their config. An empty `projects` array (`projects: []`) will now result in no projects being run, which may cause Playwright to error; to use defaults, the `projects` key should be omitted entirely. This change should be rolled back if test suites are found to depend on the merged project list, and users can instead manually add the default browser projects to their configuration.

Ecosystem Topology