-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathvite.config.ts
69 lines (61 loc) · 1.82 KB
/
vite.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { defineConfig } from "vitest/config"
import fs from "fs"
export default () => {
const testRegex = process.env.TEST_FILES?.split(",") ?? ["*Test"]
const includeRegex = `(${testRegex.join("|")})`
console.log("TEST_FILES pattern", includeRegex)
const isWindows = process.platform === "win32"
return defineConfig({
server: {
https: {
cert: fs.readFileSync("./.vitest-cert/cert.pem"),
key: fs.readFileSync("./.vitest-cert/key.pem"),
},
},
test: {
globals: true,
setupFiles: "./test/vitest-setup.ts",
include: [`test/src/**/${includeRegex}.ts`],
update: process.env.UPDATE_SNAPSHOT === "true",
name: "node",
environment: "node",
server: {
deps: {
inline: ["electron"],
},
},
deps: {
optimizer: {
web: {
enabled: true,
},
},
},
// Speed things up a bit -- these help but probably won't be needed someday
maxConcurrency: 20,
pool: "forks",
poolOptions: {
forks: {
isolate: false,
},
},
isolate: false, // only safe with the poolOptions above
slowTestThreshold: 10 * 1000,
testTimeout: (isWindows ? 8 : 5) * 1000 * 60, // disk operations can be slow. We're generous with the timeout here to account for less-performant hardware
coverage: {
reporter: ["lcov", "text"],
},
reporters: ["default", "html"],
outputFile: "coverage/sonar-report.xml",
snapshotFormat: {
printBasicPrototype: false,
},
resolveSnapshotPath: (testPath, snapshotExtension) => {
return testPath
.replace(/\.[tj]s$/, `.js${snapshotExtension}`)
.replace("/src/", "/snapshots/")
.replace("\\src\\", "\\snapshots\\")
},
},
})
}