-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.ts
54 lines (47 loc) · 1.32 KB
/
jest.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
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html
import path from 'path'
import type { Config } from '@jest/types'
import { keyBy, mapValues } from 'lodash'
import pkg from './package.json'
import { findPackages } from './scripts/findPackages'
export default async (): Promise<Config.InitialOptions> => {
const packages = await findPackages({
// 暂时忽略
exclude: [
'@zhengxs/vuepress-theme-library',
'@zhengxs/vuepress-plugin-gitalk',
'@zhengxs/vuepress-plugin-twikoo'
]
})
return {
preset: 'ts-jest',
globals: {
__DEV__: false,
__TEST__: true,
__VERSION__: pkg['version'],
'ts-jest': {
tsconfig: {
target: 'esnext',
sourceMap: true
}
}
},
coverageDirectory: 'coverage',
coverageReporters: ['html', 'lcov', 'text'],
collectCoverageFrom: packages.map(pkg =>
path.resolve(pkg['location'], 'src/**/*.ts')
),
projects: packages.map(pkg => {
return {
displayName: pkg['name'],
testMatch: [
path.resolve(pkg['location'], '__tests__/**/*.(spec|test).ts')
]
}
}),
moduleNameMapper: mapValues(keyBy(packages, 'name'), pkg =>
path.resolve(pkg['location'], 'src')
)
}
}