-
Notifications
You must be signed in to change notification settings - Fork 103
Description
Environment
- Operating System:
Darwin - Node Version:
v24.11.0 - Nuxt Version:
3.20.1 - CLI Version:
3.30.0 - Nitro Version:
2.12.9 - Package Manager:
yarn@1.22.22 - Builder:
- - User Config:
- - Runtime Modules:
- - Build Modules:
-
Reproduction
Repository: https://github.com/marcelobotega/test-utils-annotations-problem
Describe the bug
Starting from @nuxt/test-utils@3.19.0, the @vitest-environment comment annotations are completely ignored, causing all tests to run in both jsdom and nuxt environments simultaneously. This doubles test execution time and breaks the intended environment separation.
Expected Behavior
- Tests without
@vitest-environment nuxtannotation should run only in jsdom - Tests with
@vitest-environment nuxtannotation should run only in nuxt environment - Each test file should run in exactly one environment
Actual Behavior
- All tests run in both jsdom and nuxt environments regardless of annotations
- Test execution time is doubled
- Test output shows the same file running twice:
✓ |nuxt| test/simple-nuxt.spec.ts (3 tests)
✓ |jsdom| test/simple-nuxt.spec.ts (3 tests) ← Should NOT appear!
Additional context
We are still using the "simple way" approach for our test setup:
export default defineVitestConfig({
test: {
environment: 'jsdom', // Default environment
environmentOptions: {
nuxt: {
domEnvironment: 'jsdom',
// ... nuxt-specific config
},
},
},
});In our use case, the @vitest-environment annotations are really helpful for performance optimization. We have:
- 1,428 test files using jsdom (default, no annotation)
- 299 test files using Nuxt environment
- 29 test files using Node environment
I know we could create separate workspace environments and reorganize the files, but that's still significant work. I'm not sure if the change in v3.19.0+ was intentional or a bug, either way, it would be great to get confirmation so we know if we need to plan a migration 😬