-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjest.config.js
50 lines (48 loc) · 1.74 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
const path = require('path');
const JEST_STYLE_MOCK_FILE = path.resolve(__dirname, 'jest.style-mock.ts');
const JEST_FILE_MOCK_FILE = path.resolve(__dirname, 'jest.file-mock.ts');
module.exports = {
preset: 'ts-jest',
rootDir: path.resolve(__dirname, './'),
moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx', 'mjs'],
moduleNameMapper: {
'\\.(css|less|scss)$': JEST_STYLE_MOCK_FILE,
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_FILE_MOCK_FILE,
'^src/packages/(.*)$': '<rootDir>/packages/press-ui/src/packages/$1',
'^src/pages/(.*)$': '<rootDir>/packages/press-ui/src/pages/$1',
'^src/utils/(.*)$': '<rootDir>/packages/press-ui/src/utils/$1',
'^press-ui/(.*)$': '<rootDir>packages/press-ui/src/packages/$1',
},
transform: {
'\\.(vue)$': 'vue-jest',
'^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$':
'jest-transform-stub',
'^.+\\.jsx?$': 'babel-jest',
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
'^.+\\.(j|t)sx?$': 'ts-jest',
},
// transform: {
// '^.+\\.[t|j]sx?$': [
// 'babel-jest',
// {
// presets: ['@babel/preset-env', '@babel/preset-typescript'],
// },
// ],
// },
globals: {
uni: true,
getCurrentPages: true,
ROUTES: '',
weex: { requireModule: () => {} },
},
testMatch: [
'**/tests/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)',
],
testEnvironment: 'jsdom',
snapshotSerializers: ['jest-serializer-vue'],
collectCoverage: true,
coverageReporters: ['lcov', 'text-summary'],
coverageDirectory: '<rootDir>/tests/coverage',
transformIgnorePatterns: ['<rootDir>/packages/press-ui/node_modules/.pnpm/(?!(@popperjs\\+core)@)'],
};