vitest-dev / vitest-dev/vitest
Cannot re-use static `browser.instances` config across projects
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Describe the bug
Reusing the same test.browser.instances objects between test.projects crashes Vitest:
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Startup Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: Cannot define a nested project for a chromium browser. The project name "browser (chromium)" 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.
For example:
const instances: BrowserInstanceOption[] = [
{
browser: 'chromium',
provider: playwright()
},
{
browser: 'firefox',
provider: playwright(),
fileParallelism: false
}
];
export default defineConfig({
test: {
projects: [
{
extends: true,
test: {
name: 'browser',
include: ['browser/**/*.test.*'],
browser: {
enabled: true,
instances
}
}
},
{
extends: true,
test: {
name: 'visual',
include: ['visual/*.test.*'],
browser: {
enabled: true,
instances
}
}
}
]
}
});
Reproduction
Browser tests don't work in stackblitz... @vitest/browser-preview is suggested, but it doesn't work either?
Error: stackblitz environment does not support the undefined provider. Please, use "@vitest/browser-preview" instead.
System Info
System:
OS: Windows 11 10.0.26200
CPU: (32) x64 AMD Ryzen 9 9950X3D 16-Core Processor
Memory: 31.37 GB / 63.58 GB
Binaries:
Node: 25.8.1 - C:\Program Files\nodejs\node.EXE
npm: 11.10.1 - C:\Program Files\nodejs\npm.CMD
pnpm: 10.30.3 - C:\Users\Stepi\AppData\Roaming\npm\pnpm.CMD
Browsers:
Chrome: 146.0.7680.80
Edge: Chromium (146.0.3856.59)
Firefox: 148.0.2 - C:\Program Files\Mozilla Firefox\firefox.exe
npmPackages:
@vitejs/plugin-react: ^6.0.1 => 6.0.1
@vitest/browser-playwright: ^4.1.0 => 4.1.0
@vitest/coverage-istanbul: ^4.1.0 => 4.1.0
@vitest/eslint-plugin: ^1.6.12 => 1.6.12
playwright: ~1.58.0 => 1.58.2
vite: ^8.0.0 => 8.0.0
vitest: ^4.1.0 => 4.1.0
vitest-browser-react: ^2.1.0 => 2.1.0
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with vite.config.ts and the linked reproduction; compare how the shared instances are processed for the two projects and locate the duplicate nested-project name validation. Verify the configuration locally, then confirm that reusing the instances across both projects no longer crashes while project names remain unique.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- playwright, typescript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100