generated from PrivateAIM/typescript-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.config.ts
More file actions
49 lines (48 loc) · 1.67 KB
/
vitest.config.ts
File metadata and controls
49 lines (48 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import tsconfigPaths from "vite-tsconfig-paths";
import { defineVitestConfig } from "@nuxt/test-utils/config";
import path from "path";
// Intercept @sidebase/nuxt-auth AND any subpath imports (e.g. the dist
// runtime files that Nuxt's auto-import plugin injects) before Vite's
// package-exports resolver runs. A regex alias would require the array alias
// format which breaks defineVitestConfig's Nuxt virtual-module setup.
const mockNuxtAuth = {
name: "mock-nuxt-auth",
enforce: "pre" as const,
resolveId(id: string) {
// Match the package name in all forms:
// "@sidebase/nuxt-auth" – direct package import
// "@sidebase/nuxt-auth/dist/…" – package subpath import
// "…/@sidebase/nuxt-auth/…" – absolute path with package segment
// "…/@sidebase+nuxt-auth@…/…" – pnpm-mangled path from #imports
if (/[/@]sidebase[/+]nuxt-auth/.test(id)) {
return path.resolve(__dirname, "./test/mockapi/nuxt-auth-mock.ts");
}
},
};
export default defineVitestConfig({
plugins: [tsconfigPaths(), mockNuxtAuth],
test: {
globals: true,
env: {
TZ: "Europe/Berlin",
},
exclude: [
"**/node_modules/**",
"**/dist/**",
"**/cypress/**",
"**/.{idea,git,cache,output,temp}/**",
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*",
],
environment: "happy-dom",
setupFiles: "./test/mockapi/setup.ts", // Load the config for testing
coverage: {
include: ["**/app/components/**"],
},
},
resolve: {
alias: {
"~": path.resolve(__dirname, "./app"),
"@": path.resolve(__dirname, "."),
},
},
});