-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathvitest.config.ts
More file actions
85 lines (80 loc) · 2.09 KB
/
vitest.config.ts
File metadata and controls
85 lines (80 loc) · 2.09 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
import fs from 'fs';
import path from 'path';
import react from '@vitejs/plugin-react';
// Packages with broken sourcemaps (reference source files not included in npm package)
const brokenSourcemapPackages = [
'node_modules/@redhat-cloud-services',
'node_modules/@scalprum',
];
// Plugin to strip sourcemap comments from problematic packages
const stripSourcemaps = {
name: 'strip-sourcemaps',
enforce: 'pre' as const,
load(id: string) {
if (
id.endsWith('.js') &&
brokenSourcemapPackages.some((pkg) => id.includes(pkg))
) {
const code = fs.readFileSync(id, 'utf-8');
return {
code: code.replace(/\/\/# sourceMappingURL=.*/g, ''),
map: null,
};
}
return null;
},
};
const config = {
plugins: [stripSourcemaps, react()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/test/setup.ts'],
typecheck: {
tsconfig: './tsconfig.vitest.json',
},
coverage: {
provider: 'v8',
exclude: ['**/test/**', '**/tests/**', '**/mocks/**', '**/*.scss'],
},
server: {
deps: {
inline: ['vitest-canvas-mock', '@patternfly', '@monaco-editor'],
},
},
testTimeout: 10000,
fileParallelism: false,
exclude: [
'./pkg/lib/**',
'**/node_modules/**',
'**/dist/**',
'./playwright/**',
],
retry: 3,
},
reporters: ['default', 'junit'],
outputFile: {
junit: './coverage/junit.xml',
},
resolve: {
mainFields: ['module'],
alias: {
'@': path.resolve(__dirname, 'src'),
// we have to point vitest to the mocks for `cockpit` and `cockpit/fsinfo`
// by using aliases. This allows vitest to resolve these two packages
// and allows the tests to pass
cockpit: path.resolve(__dirname, 'src/test/mocks/cockpit'),
'cockpit/fsinfo': path.resolve(
__dirname,
'src/test/mocks/cockpit/fsinfo',
),
'os-release': path.resolve(__dirname, 'src/test/mocks/os-release'),
},
},
esbuild: {
loader: 'tsx',
include: /src\/.*\.[tj]sx?$/,
exclude: [],
},
};
export default config;