-
-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathvitest.config.ts
More file actions
86 lines (81 loc) · 2.12 KB
/
vitest.config.ts
File metadata and controls
86 lines (81 loc) · 2.12 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 { defineConfig, type TestProjectInlineConfiguration } from 'vitest/config'
import Vue from '@vitejs/plugin-vue'
import { fileURLToPath } from 'node:url'
import fs from 'node:fs'
const pluginsProjects: TestProjectInlineConfiguration[] = fs
.globSync('./plugins/*/')
.map((dir) => {
try {
const pkg = JSON.parse(
fs.readFileSync(fileURLToPath(new URL(`${dir}/package.json`, import.meta.url)), 'utf-8'),
)
return {
// inherit from root config
extends: true,
test: {
name: '🔌 ' + pkg.name,
root: dir,
},
} satisfies TestProjectInlineConfiguration
} catch (error) {
console.error(`Error reading package.json from "${dir}"`, error)
return null
}
})
.filter((v) => v != null)
export default defineConfig({
plugins: [Vue()],
// this allows plugins to correctly import the dev version of pinia
resolve: {
alias: {
'@pinia/colada': fileURLToPath(new URL('./src/index.ts', import.meta.url)),
},
},
test: {
projects: [
{
// inherit from root config
extends: true,
test: {
root: '.',
name: {
label: '🍹 @pinia/colada',
color: 'white',
},
},
},
...pluginsProjects,
// TODO: once they upgrade to vitest 4
// './nuxt',
],
// common config for all projects
include: ['src/**/*.{test,spec}.ts'],
environment: 'happy-dom',
fakeTimers: {
// easier to read, some date in 2001
now: 1_000_000_000_000,
},
typecheck: {
enabled: true,
},
coverage: {
enabled: true,
provider: 'v8',
reporter: ['text', 'lcovonly', 'html'],
include: ['src', 'plugins/*/src'],
exclude: [
//
'**/src/index.ts',
'test-utils',
'src/utils.ts',
// we are not event sure to keep them because we have
// our own devtools
'src/devtools',
// just for show, so better not include in coverage
// as it has no tests
'plugins/debug',
'**/*.test-d.ts',
],
},
},
})