forked from vuepress/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
62 lines (58 loc) · 1.79 KB
/
jest.config.js
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
const { readdirSync } = require('fs')
const { resolve } = require('path')
const { compilerOptions } = require('./tsconfig.base.json')
const packagesDir = 'packages/@vuepress'
const packages = readdirSync(resolve(__dirname, packagesDir), {
withFileTypes: true,
})
.filter((item) => item.isDirectory())
.map(({ name }) => name)
const commonPackages = packages.filter(
(item) => !item.startsWith('plugin-') && !item.startsWith('theme-')
)
const pluginAndThemePackages = packages.filter(
(item) => item.startsWith('plugin-') || item.startsWith('theme-')
)
module.exports = {
rootDir: resolve(__dirname),
testEnvironment: 'node',
preset: 'ts-jest',
globals: {
'ts-jest': {
tsconfig: {
...compilerOptions,
module: 'CommonJS',
sourceMap: true,
},
},
'__VUEPRESS_VERSION__': '',
'__VUEPRESS_DEV__': false,
'__VUEPRESS_SSR__': false,
},
moduleNameMapper: {
[`^@vuepress/(${commonPackages.join(
'|'
)})$`]: `<rootDir>/${packagesDir}/$1/src`,
[`^@vuepress/(${pluginAndThemePackages.join(
'|'
)})$`]: `<rootDir>/${packagesDir}/$1/src/node`,
'^@internal/(.*)$': `<rootDir>/packages/@vuepress/client/__tests__/__fixtures__/$1`,
'.+\\.(css|styl|less|sass|scss)$':
'<rootDir>/packages/@vuepress/client/__tests__/__fixtures__/styleMock',
},
testMatch: ['<rootDir>/packages/**/__tests__/**/*.spec.ts'],
testPathIgnorePatterns: [
'/node_modules/',
'/__fixtures__/',
'@vuepress/client',
],
snapshotSerializers: [require.resolve('jest-serializer-vue')],
// coverage config
collectCoverageFrom: [
'<rootDir>/packages/**/src/**/*.ts',
'!<rootDir>/packages/@vuepress/client/**/*',
'!<rootDir>/packages/@vuepress/*/src/client/**/*',
'!**/*.d.ts',
],
coverageDirectory: 'coverage',
}