-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.mts
More file actions
68 lines (65 loc) · 1.76 KB
/
vitest.config.mts
File metadata and controls
68 lines (65 loc) · 1.76 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
/**
* @file Configuration - Vitest
* @module config/vitest
* @see https://vitest.dev/config
*/
import Notifier from '#tests/reporters/notifier'
import pathe from '@flex-development/pathe'
import ci from 'is-ci'
import {
defineConfig,
type ConfigEnv,
type ViteUserConfig
} from 'vitest/config'
import pkg from './package.json' with { type: 'json' }
import tsconfig from './tsconfig.json' with { type: 'json' }
export default defineConfig(config)
/**
* Create a vitest configuration.
*
* @see {@linkcode ConfigEnv}
* @see {@linkcode ViteUserConfig}
*
* @this {void}
*
* @param {ConfigEnv} env
* Configuration environment
* @return {ViteUserConfig}
* Root vitest configuration object
*/
function config(this: void, env: ConfigEnv): ViteUserConfig {
return {
resolve: {
conditions: tsconfig.compilerOptions.customConditions
},
test: {
include: ['src/**/__tests__/*.spec-d.mts'],
outputFile: {
blob: pathe.join('.vitest-reports', env.mode + '.blob.json'),
json: pathe.join('__tests__', 'reports', env.mode + '.json'),
junit: pathe.join('__tests__', 'reports', env.mode + '.junit.xml')
},
passWithNoTests: true,
reporters: JSON.parse(process.env['VITEST_UI'] ?? '0')
? [new Notifier(), ['tree']]
: env.mode === 'reports'
? [['tree']]
: [
ci ? 'github-actions' : new Notifier(),
'blob',
'json',
['junit', { suiteName: pkg.name }],
['tree']
],
typecheck: {
allowJs: false,
checker: 'tsc',
enabled: env.mode === 'typecheck',
ignoreSourceErrors: false,
include: ['**/__tests__/*.spec-d.mts'],
only: true,
tsconfig: 'tsconfig.test.json'
}
}
}
}