-
Notifications
You must be signed in to change notification settings - Fork 143
/
vitest.config.mts
72 lines (61 loc) · 2.29 KB
/
vitest.config.mts
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
import fs from 'fs';
import path from 'path';
import vue from "@vitejs/plugin-vue";
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import type { UserConfigExport } from 'vite';
function generateConfig(): Promise<UserConfigExport> {
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.*',
];
const rawData = fs.readFileSync(
path.join(filePath, '.frontend-configuration-settings.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()],
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);
})();