Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
68 lines (65 loc) · 2.48 KB
/
Copy pathvitest.config.ts
File metadata and controls
68 lines (65 loc) · 2.48 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
/*********************************************************************
* Copyright (c) Intel Corporation 2020
* SPDX-License-Identifier: Apache-2.0
**********************************************************************/
import { coverageConfigDefaults, defineConfig } from 'vitest/config'
// Treat only affirmative values as CI so e.g. CI=false stays local behavior.
const isCI = /^(true|1)$/i.test(process.env.CI ?? '')
export default defineConfig({
test: {
// Mirrors the previous jest `testMatch`. The `.spec.js` entry is required
// for src/test/zlib.spec.js, which exercises the vendored CJS zlib module.
include: [
'src/test/**/*.test.ts',
'src/test/**/*.spec.ts',
'src/test/**/*.spec.js'
],
// The suite relied on jest's implicit globals (via @types/jest) for
// `describe`/`it`/`expect`/`beforeEach`. Enabling globals preserves that
// across ~1100 assertion sites; only `vi` is imported explicitly. Matches
// the pattern already used in mps, rps and ui-toolkit-react.
globals: true,
environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'],
// The RLE/image-decoding suites are memory hungry — the jest script ran
// with --runInBand for this reason. `poolOptions.forks.singleFork` was
// removed in Vitest 4; fileParallelism: false is the supported equivalent
// and runs one test file at a time.
pool: 'forks',
fileParallelism: false,
// Restore anything installed via vi.stubGlobal (e.g. the FileReader mock
// in amtider.spec.ts) after each test so mocks never leak across tests.
unstubGlobals: true,
reporters: isCI ? [
'default',
'junit',
'github-actions'
] : ['default'],
outputFile: {
junit: 'junit.xml'
},
coverage: {
provider: 'v8',
reportsDirectory: './coverage',
reporter: [
'text',
'lcov',
'clover',
'json'
],
include: ['src/core/**/*.{ts,js}'],
exclude: [
...coverageConfigDefaults.exclude,
'src/**/*.d.ts',
'src/test/**',
// The coverage script skips the memory-hungry rledecoder/imagehelper
// suites (see the --exclude flags in package.json), so keep their
// targets out of the denominator instead of reporting near-zero
// coverage for files that are actually tested by `npm run test`.
// Globs so the excludes survive a file move.
'**/RLEDecoder.ts',
'**/ImageHelper.ts'
]
}
}
})