-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvitest.config.ts
More file actions
53 lines (50 loc) · 1.47 KB
/
Copy pathvitest.config.ts
File metadata and controls
53 lines (50 loc) · 1.47 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
50
51
52
53
import { configDefaults, defineConfig } from "vitest/config";
import path from "node:path";
import os from "node:os";
import viteConfig from "./vite.config";
// Node 26+ emits an experimental-localStorage warning unless --localstorage-file
// is provided. Suppress it only for test workers; the flag is unknown on Node 22.
const nodeMajor = parseInt(process.versions.node.split(".")[0]!, 10);
if (
nodeMajor >= 26 &&
!process.env.NODE_OPTIONS?.includes("--localstorage-file")
) {
process.env.NODE_OPTIONS = `${process.env.NODE_OPTIONS ?? ""} --localstorage-file=${path.join(
os.tmpdir(),
"vitest-localstorage",
)}`.trim();
}
const resolvedViteConfig = typeof viteConfig === "function" ? (viteConfig as () => Record<string, unknown>)() : viteConfig;
export default defineConfig({
...resolvedViteConfig,
test: {
environment: "jsdom",
globals: true,
setupFiles: ["./tests/setup.ts"],
exclude: [...configDefaults.exclude, "inactive-features/**"],
fileParallelism: false,
pool: "forks",
testTimeout: 30000,
coverage: {
provider: "v8",
reporter: ["text", "json", "html"],
thresholds: {
branches: 61,
functions: 68,
lines: 73,
statements: 70,
},
exclude: [
"node_modules/",
"dist/",
"dist-electron/",
"release/",
"scripts/",
"**/*.test.ts",
"**/*.test.tsx",
"vite.config.ts",
"vitest.config.ts",
],
},
},
});