forked from mx-space/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.config.ts
81 lines (72 loc) · 1.77 KB
/
vitest.config.ts
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
import { resolve } from 'path'
import swc from 'rollup-plugin-swc'
import tsconfigPath from 'vite-tsconfig-paths'
import { defineConfig } from 'vitest/config'
const swcPlugin = (() => {
const plugin = swc({
test: 'ts',
jsc: {
parser: {
syntax: 'typescript',
dynamicImport: true,
decorators: true,
},
target: 'es2021',
transform: {
decoratorMetadata: true,
},
},
})
const originalTransform = plugin.transform!
// @ts-ignore
const transform = function (...args: Parameters<typeof originalTransform>) {
// @ts-ignore
if (!args[1].endsWith('html')) return originalTransform.apply(this, args)
}
return { ...plugin, transform }
})()
export default defineConfig({
root: './test',
test: {
include: ['**/*.spec.ts', '**/*.e2e-spec.ts'],
threads: false,
globals: true,
globalSetup: [resolve(__dirname, './test/setup.ts')],
setupFiles: [resolve(__dirname, './test/setup-global.ts')],
environment: 'node',
includeSource: [resolve(__dirname, './test')],
},
optimizeDeps: {
needsInterop: ['lodash'],
},
resolve: {
alias: {
'zx-cjs': 'zx',
'~/app.config': resolve(__dirname, './src/app.config.test.ts'),
'~/common/decorators/auth.decorator': resolve(
__dirname,
'./test/mock/decorators/auth.decorator.ts',
),
},
},
// esbuild can not emit ts metadata
esbuild: false,
plugins: [
// @ts-ignore
swcPlugin,
tsconfigPath({
projects: [
resolve(__dirname, './test/tsconfig.json'),
resolve(__dirname, './tsconfig.json'),
],
}),
{
name: 'vitest-plugin',
config: () => ({
test: {
setupFiles: ['./setupFiles/lifecycle.ts'],
},
}),
},
],
})