test-utils
test-utils copied to clipboard
Can not load config with environment set to 'happy-dom'
Environment
- Operating System: Linux
- Node Version: v20.19.1
- Nuxt Version: 3.17.6
- CLI Version: 3.25.1
- Nitro Version: 2.11.13
- Package Manager: [email protected]
- Builder: -
- User Config: future, modules, compatibilityDate, devtools, postcss, tailwindcss
- Runtime Modules: @nuxt/test-utils/[email protected], @nuxtjs/[email protected], @pinia/[email protected]
- Build Modules: -
Reproduction
https://stackblitz.com/edit/nuxt-starter-w6vnmxtk
Describe the bug
Run pnpm run test, see error that config can't be loaded. Works with environment set to different value.
Additional context
No response
Logs
Hey @FlorianWerndl have you found a workaround? I'm unable to add testing to my project.
Hi @Zachiah
this is how my config looks likes now. All unit.spec.* files are running with happy-dom and all nuxt.spec.* files with nuxt (using also happy-dom afaik).
import { defineVitestProject } from '@nuxt/test-utils/config';
import { configDefaults, defineConfig } from 'vitest/config';
export default defineConfig({
test: {
reporters: ['default', 'junit'],
outputFile: './coverage/junit.xml',
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
reportsDirectory: './coverage',
include: ['app/**/**.*'],
exclude: [
...(configDefaults.coverage?.exclude ?? []),
'app/assets/**',
'app/types/**',
'app/utils/constants.js',
],
},
projects: [
await defineVitestProject({
test: {
name: 'happy-dom',
environment: 'happy-dom',
globals: true,
include: ['**/*.unit.spec.{ts,js}'],
},
}),
await defineVitestProject({
test: {
name: 'nuxt',
environment: 'nuxt',
globals: true,
include: ['**/*.nuxt.spec.{ts,js}'],
},
}),
],
setupFiles: ['./vitest.setup.ts'],
},
});