-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvitest.config.ts
More file actions
58 lines (55 loc) · 1.84 KB
/
vitest.config.ts
File metadata and controls
58 lines (55 loc) · 1.84 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
import {createHash} from 'node:crypto'
import {defineConfig} from 'vitest/config'
const IS_AGENT = Boolean(process.env.CLAUDECODE || process.env.CODEX_CI)
const cwdHash = createHash('sha1').update(process.cwd()).digest('hex').slice(0, 8)
const OUTPUT_FILE = IS_AGENT ? {json: `/tmp/test-results-${cwdHash}.json`} : undefined
export default defineConfig({
// This is needed to avoid listening to changes in the tmp directory
// Without this, watch will go in an infinite loop
server: {
watch: {
ignored: ['**/tmp/**/*'],
},
},
test: {
coverage: {
exclude: [
'**/*.{test,spec,stories,d}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
'fixtures/**',
'packages/@sanity/cli/test/**',
'packages/@sanity/cli/templates/**',
// Vitest 4.0 no longer auto-excludes these directories
'**/dist/**',
'**/tmp/**',
'**/test/**',
'**/__tests__/**',
'**/coverage/**',
'**/.git/**',
],
include: [
'packages/@sanity/cli/**/*.{ts,tsx}',
'packages/@sanity/cli-core/**/*.{ts,tsx}',
'packages/create-sanity/**/*.{ts,tsx}',
],
provider: 'istanbul',
reporter: ['html', 'json', 'json-summary'],
},
// Add explicit exclude for test execution
exclude: ['**/node_modules/**', '**/dist/**', '**/tmp/**', '**/.git/**'],
onUnhandledError(error) {
/**
* Ignore unhandled errors on Windows + Node 20 to avoid flaky tests
*/
if (
process.platform === 'win32' &&
process.version.startsWith('v20.') &&
error.message.includes('Worker forks emitted error')
) {
return false
}
},
outputFile: OUTPUT_FILE,
projects: ['packages/@sanity/cli', 'packages/@sanity/cli-core', 'packages/create-sanity'],
reporters: ['default', ...(IS_AGENT ? ['json'] : [])],
},
})