-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.config.mts
More file actions
109 lines (100 loc) · 3.28 KB
/
Copy pathvitest.config.mts
File metadata and controls
109 lines (100 loc) · 3.28 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import fs from 'fs';
import path from 'path';
import vue from '@vitejs/plugin-vue';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vitest/config';
import type { UserConfig } from 'vitest/config';
function generateConfig(): Promise<UserConfig> {
return new Promise((resolve, reject) => {
const filePath = path.dirname(fileURLToPath(import.meta.url));
const exclude = [
'**/*.d.ts',
'**/node_modules/**',
'**/dist/**',
'**/install/**',
'**/cypress/**',
'**/.{idea,git,cache,output,temp}/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
'**/build/**',
'**/staticfiles/**',
// Generated Zod schemas (see openapi-ts.config.ts).
'**/client/zod.gen.ts',
// Theme token data, no logic.
'**/primevue-bcgov-preset.ts',
];
const rawData = fs.readFileSync(
path.join(
__dirname,
'frontend_configuration',
'webpack-metadata.json',
),
'utf-8',
);
const parsedData = JSON.parse(rawData);
const alias: { [key: string]: string } = {
'@/arches': path.join(
parsedData['ROOT_DIR'],
'app',
'src',
'arches',
),
arches: path.join(
parsedData['ROOT_DIR'],
'app',
'media',
'js',
'arches.js',
),
};
for (const [
archesApplicationName,
archesApplicationPath,
] of Object.entries(
parsedData['ARCHES_APPLICATIONS_PATHS'] as {
[key: string]: string;
},
)) {
alias[`@/${archesApplicationName}`] = path.join(
archesApplicationPath,
'src',
archesApplicationName,
);
}
resolve({
plugins: [vue() as any],
resolve: {
// Force these bare imports to resolve from this repo's
// node_modules, regardless of where the importing file lives.
dedupe: ['vue', 'dompurify', 'primevue'],
},
test: {
alias: alias,
coverage: {
include: [
path.join(
parsedData['APP_RELATIVE_PATH'],
'src',
path.sep,
),
],
exclude: exclude,
reporter: [['clover', { file: 'coverage.xml' }], 'text'],
reportsDirectory: path.join(
filePath,
'coverage',
'frontend',
),
},
environment: 'jsdom',
globals: true,
exclude: exclude,
passWithNoTests: true,
setupFiles: ['vitest.setup.mts'],
},
});
});
}
export default (async () => {
const config = await generateConfig();
return defineConfig(config);
})();