{"record":{"id":"31c54bfbaace443e","repo":"vitest-dev/vitest","slug":"cannot-define-a-nested-project-for-a-browser-br","errorCode":null,"errorMessage":"Cannot define a nested project for a ${browser} browser. The project name \"${name}\" was already defined. If you have multiple instances for the same browser, make sure to define a custom \"name\". All projects should have unique names. Make sure your configuration is correct.","messagePattern":"Cannot define a nested project for a (.+?) browser\\. The project name \"(.+?)\" was already defined\\. If you have multiple instances for the same browser, make sure to define a custom \"name\"\\. All projects should have unique names\\. Make sure your configuration is correct\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/projects/resolveProjects.ts","lineNumber":946,"sourceCode":"            `@vitest/coverage-v8 does not work with\\n${browserConfig}\\n`\n            + `\\nUse either:\\n${correctExample}`\n            + `\\n\\n...or change your coverage provider to:\\n${coverageExample}\\n`,\n          )\n        }\n\n        if (globalConfig.inspect || globalConfig.inspectBrk) {\n          const inspectOption = `--inspect${globalConfig.inspectBrk ? '-brk' : ''}`\n\n          throw new Error(\n            `${inspectOption} does not work with\\n${browserConfig}\\n`\n            + `\\nUse either:\\n${correctExample}`\n            + `\\n\\n...or disable ${inspectOption}\\n`,\n          )\n        }\n      }\n\n      if (names.has(name)) {\n        throw new Error(\n          [\n            `Cannot define a nested project for a ${browser} browser. The project name \"${name}\" was already defined. `,\n            'If you have multiple instances for the same browser, make sure to define a custom \"name\". ',\n            'All projects should have unique names. Make sure your configuration is correct.',\n          ].join(''),\n        )\n      }\n      names.add(name)\n\n      const clonedConfig = cloneProjectConfigForBrowserInstance(projectConfig, instance)\n      clonedConfig.name = name\n\n      result.push({\n        viteConfig, // shared with parent\n        projectConfig: clonedConfig,\n        ancestors: entry.ancestors,\n      })\n    })","sourceCodeStart":928,"sourceCodeEnd":964,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/projects/resolveProjects.ts#L928-L964","documentation":"Every browser instance becomes a distinct nested project and is registered in a shared `names` set. If two instances resolve to the same project name, the second registration is rejected. The default name is derived from the browser (plus instance fields), so two instances of the same browser without explicit `name` values collide.","triggerScenarios":"`names.has(name)` is true inside the per-instance loop after `name = instance.name`. Common: `instances: [{ browser: 'chromium' }, { browser: 'chromium' }]`, or two instances whose explicit `name` is identical.","commonSituations":"Running the same browser in parallel (e.g. one headed, one headless); copy-pasting an instance block and forgetting to set a unique `name`.","solutions":["Give each colliding browser instance a unique `name` field.","Remove the duplicate instance if it was unintended.","If you need the same browser twice, distinguish them by `name` (and optionally `headless`/launch options)."],"exampleFix":"// before\nbrowser: {\n  provider: 'playwright',\n  instances: [\n    { browser: 'chromium', headless: false },\n    { browser: 'chromium', headless: true },\n  ],\n}\n\n// after\nbrowser: {\n  provider: 'playwright',\n  instances: [\n    { name: 'chromium-headed', browser: 'chromium', headless: false },\n    { name: 'chromium-headless', browser: 'chromium', headless: true },\n  ],\n}","handlingStrategy":"validation","validationCode":"// Verify browser instance names are unique before starting Vitest.\nfunction assertUniqueBrowserInstances(browser: { instances?: Array<{ name?: string; browser: string }> }) {\n  const seen = new Set<string>()\n  for (const i of browser.instances ?? []) {\n    const name = i.name ?? i.browser\n    if (seen.has(name)) {\n      throw new Error(`Duplicate browser instance name '${name}'. Set a unique \"name\" on each instance.`)\n    }\n    seen.add(name)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set an explicit `name` when defining more than one instance per browser.","Add a unit test over your config that asserts all project (and instance) names are unique."],"tags":["browser","config","naming"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}