generated from MapColonies/ts-server-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.mts
More file actions
66 lines (62 loc) · 1.76 KB
/
vitest.config.mts
File metadata and controls
66 lines (62 loc) · 1.76 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
import { defineConfig, ViteUserConfig } from 'vitest/config';
import tsconfig from './tsconfig.json';
import path from 'path';
// Create an alias object from the paths in tsconfig.json
const pathAlias = Object.fromEntries(
// For Each Path in tsconfig.json
Object.entries(tsconfig.compilerOptions.paths).map(([key, [value]]) => [
// Remove the "/*" from the key and resolve the path
key.replace('/*', ''),
// Remove the "/*" from the value Resolve the relative path
path.resolve(__dirname, value.replace('/*', '')),
])
);
const reporters: Exclude<ViteUserConfig['test'], undefined>['reporters'] = ['default', 'html'];
if (process.env.GITHUB_ACTIONS) {
reporters.push('github-actions');
}
export default defineConfig({
test: {
projects: [
{
test: {
name: 'unit',
setupFiles: ['./tests/configurations/vitest.setup.ts'],
include: ['tests/unit/**/*.spec.ts'],
environment: 'node',
},
resolve: {
alias: pathAlias,
},
},
{
test: {
name: 'integration',
setupFiles: ['./tests/configurations/vitest.setup.ts'],
include: ['tests/integration/**/*.spec.ts'],
environment: 'node',
globalSetup: './tests/configurations/vitest.globalSetup.ts',
},
resolve: {
alias: pathAlias,
},
},
],
reporters,
coverage: {
enabled: true,
reporter: ['text', 'html', 'json', 'json-summary'],
include: ['src/**/*.ts'],
exclude: ['**/vendor/**', 'node_modules/**'],
reportOnFailure: true,
thresholds: {
global: {
statements: 80,
branches: 80,
functions: 80,
lines: 80,
},
},
},
},
});