-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvitest.config.ts
51 lines (47 loc) · 1.3 KB
/
vitest.config.ts
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
50
51
import { fileURLToPath } from "url"
import react from "@vitejs/plugin-react"
import tsConfigPaths from "vite-tsconfig-paths"
import {
mergeConfig as _mergeConfig,
defaultExclude,
defineConfig,
} from "vitest/config"
/* eslint-disable @typescript-eslint/no-explicit-any */
export const mergeConfig = (
base: Record<string, any>,
config: Record<string, any>,
) => _mergeConfig(base, config)
/* eslint-enable @typescript-eslint/no-explicit-any */
export const baseConfig = defineConfig({
plugins: [tsConfigPaths({ projects: [`./testing.json`] })],
test: {
globals: true,
environment: "node",
coverage: {
reporter: ["html", "text", "json"],
},
},
})
export const reactConfig = mergeConfig(baseConfig, {
plugins: [react()],
test: {
environment: "jsdom",
},
})
export default mergeConfig(reactConfig, {
resolve: {
// needed for the tests to work
alias: {
"@/src": fileURLToPath(new URL("./src", import.meta.url)),
"@/components": fileURLToPath(
new URL("./src/components", import.meta.url),
),
"@/lib": fileURLToPath(new URL("./src/lib", import.meta.url)),
},
},
test: {
setupFiles: "src/tests/utils/setupTests.ts",
exclude: [...defaultExclude, "**/e2e/**/*"],
include: ["src/**/*.(spec|test).{js,jsx,ts,tsx}"],
},
})