forked from vitest-dev/vitest
/
defaults.ts
98 lines (92 loc) · 2.93 KB
/
defaults.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import type { BenchmarkUserOptions, ResolvedCoverageOptions, UserConfig } from './types'
import { isCI } from './utils/env'
export const defaultInclude = ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
export const defaultExclude = ['**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*']
export const benchmarkConfigDefaults: Required<Omit<BenchmarkUserOptions, 'outputFile'>> = {
include: ['**/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
exclude: defaultExclude,
includeSource: [],
reporters: ['default'],
}
const defaultCoverageExcludes = [
'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}',
]
// These are the generic defaults for coverage. Providers may also set some provider specific defaults.
export const coverageConfigDefaults: ResolvedCoverageOptions = {
provider: 'c8',
enabled: false,
clean: true,
cleanOnRerun: true,
reportsDirectory: './coverage',
exclude: defaultCoverageExcludes,
reporter: [['text', {}], ['html', {}], ['clover', {}], ['json', {}]],
// default extensions used by c8, plus '.vue' and '.svelte'
// see https://github.com/istanbuljs/schema/blob/master/default-extension.js
extension: ['.js', '.cjs', '.mjs', '.ts', '.mts', '.cts', '.tsx', '.jsx', '.vue', '.svelte'],
}
export const fakeTimersDefaults = {
loopLimit: 10_000,
shouldClearNativeTimers: true,
toFake: [
'setTimeout',
'clearTimeout',
'setInterval',
'clearInterval',
'setImmediate',
'clearImmediate',
'Date',
],
} as NonNullable<UserConfig['fakeTimers']>
const config = {
allowOnly: !isCI,
watch: !isCI,
globals: false,
environment: 'node' as const,
threads: true,
clearMocks: false,
restoreMocks: false,
mockReset: false,
include: defaultInclude,
exclude: defaultExclude,
testTimeout: 5000,
hookTimeout: 10000,
teardownTimeout: 10000,
isolate: true,
watchExclude: ['**/node_modules/**', '**/dist/**'],
forceRerunTriggers: [
'**/package.json/**',
'**/{vitest,vite}.config.*/**',
],
update: false,
reporters: [],
silent: false,
api: false,
ui: false,
uiBase: '/__vitest__/',
open: true,
css: {
include: [],
},
coverage: coverageConfigDefaults,
fakeTimers: fakeTimersDefaults,
maxConcurrency: 5,
dangerouslyIgnoreUnhandledErrors: false,
typecheck: {
checker: 'tsc' as const,
include: ['**/*.{test,spec}-d.{ts,js}'],
exclude: defaultExclude,
},
slowTestThreshold: 300,
}
export const configDefaults: Required<Pick<UserConfig, keyof typeof config>> = Object.freeze(config)