-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
50 lines (46 loc) · 1.55 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 fs = require('fs')
const path = require('path')
const resolve = require('resolve')
process.env.BABEL_ENV = 'test'
process.env.NODE_ENV = 'test'
process.env.PUBLIC_URL = ''
require('react-scripts/config/env')
module.exports = {
roots: ['<rootDir>/src'],
testMatch: ['**/__tests__/**/*.(js|ts|tsx)'],
testEnvironment: resolve.sync('jest-environment-jsdom', {
basedir: require.resolve('jest'),
}),
testPathIgnorePatterns: ['/node_modules/'],
setupFiles: [require.resolve('whatwg-fetch')],
// some of the exercise branches don't have setupTests.js
setupFilesAfterEnv: fs.existsSync('src/setupTests.js')
? ['<rootDir>/src/setupTests.js']
: [],
moduleDirectories: ['node_modules', path.join(__dirname, './src')],
transform: {
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': require.resolve(
'react-scripts/config/jest/babelTransform',
),
'^.+\\.css$': require.resolve('react-scripts/config/jest/cssTransform.js'),
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': require.resolve(
'react-scripts/config/jest/fileTransform.js',
),
},
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
resetMocks: true,
collectCoverageFrom: [
'src/**/*.(js|ts|tsx)',
'!<rootDir>/node_modules/**/*',
'!<rootDir>/src/test/**/*',
'!<rootDir>/src/setupProxy*',
'!<rootDir>/src/setupTests*',
'!<rootDir>/src/dev-tools/**/*',
'!<rootDir>/src/types/**/*',
'!<rootDir>/src/use-keyboard-shortcut*',
],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
}