-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.config.ts
More file actions
86 lines (84 loc) · 2.68 KB
/
vitest.config.ts
File metadata and controls
86 lines (84 loc) · 2.68 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vitest/config'
import { readFileSync } from 'node:fs'
import { resolve, dirname } from 'node:path'
import vue from '@vitejs/plugin-vue'
// Read version from package.json
const packageJson = JSON.parse(
readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), './package.json'), 'utf-8')
)
const rawVersion = process.env.VERSION ?? packageJson.version
const appVersion = /^[0-9a-f]{40}$/i.test(rawVersion) ? rawVersion.slice(0, 7) : rawVersion
const buildDate = process.env.BUILD_DATE ?? new Date().toISOString()
const deployDate = process.env.DEPLOY_DATE ?? buildDate
export default defineConfig({
plugins: [vue()],
define: {
__APP_VERSION__: JSON.stringify(appVersion),
__BUILD_DATE__: JSON.stringify(buildDate),
__DEPLOY_DATE__: JSON.stringify(deployDate),
},
test: {
// enable jest-like global test APIs
globals: true,
// simulate DOM with happy-dom
environment: 'happy-dom',
// Exclude helper script packages and their test folders so running
// vitest from the repository root does not pick up ETL/test helpers.
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/e2e/**',
'src/**/__tests__/unit.setup.ts',
'**/scripts/**',
'**/scripts/**/test/**'
],
root: fileURLToPath(new URL('./', import.meta.url)),
setupFiles: [
'./src/components/__tests__/unit.setup.ts',
'./test/mocks/useIndexedDB.mock.ts',
'./test/mocks/useShardLoader.mock.ts'
],
coverage: {
provider: 'v8',
enabled: true,
reporter: ['text', 'json', 'html', 'lcov'],
include: [
'src/stores/**/*.ts',
'src/composables/**/*.ts'
],
exclude: [
'src/composables/useIndexedDB.ts',
'src/composables/useShardLoader.ts',
'coverage/**',
'dist/**',
'packages/*/test{,s}/**',
'**/*.d.ts',
'cypress/**',
'test{,s}/**',
'test{,-*}.{js,cjs,mjs,ts,tsx,jsx}',
'**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}',
'**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}',
'**/__tests__/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
'**/.{eslint,mocha,prettier}rc.{js,cjs,yml}',
'src/assets/**',
// don't try to collect coverage from standalone script packages
'scripts/**',
'scripts/**'
],
thresholds: {
lines: 75,
functions: 90,
branches: 65,
statements: 75
}
}
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'@test': fileURLToPath(new URL('./test', import.meta.url))
}
}
})