-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Labels
Description
Environment
"@nuxt/test-utils": "^3.19.2",
"vitest": "^3.2.3"
--
- Operating System: Windows_NT
- Node Version: v22.16.0
- Nuxt Version: 3.17.6
- CLI Version: 3.25.1
- Nitro Version: 2.11.13
- Package Manager: npm@10.9.2
- Builder: -
- User Config: runtimeConfig, ssr, alias, compatibilityDate, devtools, css, vite, modules
- Runtime Modules: @nuxt/test-utils/module@3.19.2, @pinia/nuxt@0.11.1
- Build Modules: -
Reproduction
Similar to here.
Ist about the nuxt environment.
I changed it from happy-dom
to nuxt
. Since then it is not coverging pages.
The Stackoverflow user had a much simpler set up without projects.
import {
defineVitestConfig,
defineVitestProject,
} from "@nuxt/test-utils/config";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import { configDefaults, defineConfig } from "vitest/config";
// 1️⃣ Nuxt-specific setup via defineVitestConfig
const nuxtConfig = defineVitestConfig({
test: {
environment: "nuxt",
globals: true,
},
});
// 2️⃣ Full Vitest config using core defineConfig
export default defineConfig({
...nuxtConfig,
test: {
coverage: {
provider: "v8",
reporter: ["text", "json", "html"],
reportsDirectory: "./tests/coverage",
exclude: [
...(configDefaults.coverage?.exclude ?? []),
"**/*.cy.ts",
"**/*.cy.tsx",
"**/cypress/**",
"nuxt.config.ts",
"scripts/**",
],
thresholds: { statements: 90, branches: 90, functions: 0, lines: 90 },
},
projects: [
{
test: {
name: "Server (Node Environment)",
include: ["tests/server/**/*.{test,spec}.ts"],
globals: true,
environment: "node",
},
plugins: [vue(), AutoImport({ imports: ["vue"], dts: true })],
},
await defineVitestProject({
test: {
name: "Happy NUXT Environment",
include: [
"tests/pages/**/*.{test,spec}.ts",
"tests/components/**/*.{test,spec}.ts",
"tests/composables/**/*.{test,spec}.ts",
"tests/utils/**/*.{test,spec}.ts",
"tests/plugins/**/*.{test,spec}.ts",
"tests/layouts/**/*.{test,spec}.ts",
"tests/directives/**/*.{test,spec}.ts",
"tests/mixins/**/*.{test,spec}.ts",
"tests/app.test.ts",
"Tests/error.test.ts",
],
exclude: ["tests/server/*.{test,spec}.ts"],
globals: true,
environment: "nuxt",
setupFiles: ["./tests/setup.ts"],
},
}),
],
},
});
Describe the bug
nuxt environment doesn't create coverage for pages
Additional context
I tried additionally and explicitly adding pages to includes. But it doesn't work.
Please, tag me, if it requires to be opened up in a different repository, such as vitest.