-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathjest.config.js
78 lines (77 loc) · 2.32 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
module.exports = {
collectCoverage: true,
collectCoverageFrom: [
'./src/**/*.{ts,tsx}',
'!./src/**/*.stories.tsx',
'!./src/**/*graphql.ts',
'!./src/**/*.d.ts',
'!**/*.test.ts*',
],
coverageReporters: ['text', 'lcov'],
testPathIgnorePatterns: ['/node_modules/', '.eslintrc.js'],
projects: [
{
// client-side testing config
displayName: 'Test client',
testMatch: [
'<rootDir>/src/client/**/*.test.ts*',
'<rootDir>/plugins/**/*.test.tsx',
'<rootDir>/plugins/**/*.client.tsx',
],
setupFiles: ['./__mocks__/fetch.js'],
testEnvironment: 'jsdom',
snapshotResolver: './__mocks__/snapshotResolver',
moduleNameMapper: {
'\\.svg': '<rootDir>/__mocks__/svgrMock.js', // see https://github.com/smooth-code/svgr/issues/83
'\\.(css|less)$': 'jest-transform-css',
'\\.(jpg|jpeg|png|gif)$': '<rootDir>/__mocks__/svgrMock.js',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
'^.+\\.css$': 'jest-transform-css',
},
setupFilesAfterEnv: ['./src/client/setupTests.js'],
},
{
// server-side testing config
displayName: 'Test server',
testMatch: [
'<rootDir>/src/server/**/*.test.ts',
'<rootDir>/plugins/**/*.test.ts',
'<rootDir>/plugins/**/*.server.test.ts',
],
setupFiles: ['./__mocks__/env.js'],
testEnvironment: 'node',
snapshotResolver: './__mocks__/snapshotResolver',
// we can only have one preset at a time
// this uses the typescript preset's transformer
// and mongo's preset to allow both to coeexist
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
preset: '@shelf/jest-mongodb',
},
{
// testing config for ./common
displayName: 'Test other',
testMatch: ['<rootDir>/src/common/**/*.test.ts'],
setupFiles: ['./__mocks__/env.js'], // eslint-disable-line import/no-extraneous-dependencies
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
testPathIgnorePatterns: ['.eslintrc.js'],
},
{
displayName: 'Add Happo/Storybook tests to code coverage numbers',
testMatch: ['<rootDir>/.storyshots/index.js'],
moduleNameMapper: {
'\\.svg': '<rootDir>/__mocks__/svgrMock.js', // see https://github.com/smooth-code/svgr/issues/83
'\\.(css|less)$': 'jest-transform-css',
'\\.(jpg|jpeg|png|gif)$': '<rootDir>/__mocks__/svgrMock.js',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
},
],
};