forked from kentcdodds/bookshelf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
58 lines (54 loc) · 1.88 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
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'],
testEnvironment: resolve.sync('jest-environment-jsdom', {
basedir: require.resolve('jest'),
}),
// this testPathIgnorePatterns config just makes things work with the way we
// have to do things for this workshop to work. You shouldn't need this in
// your own jest config. NOTE: This is the *entire* reason we need a custom
// jest config. Otherwise we'd be able to use regular react-scripts
// so in your apps, react-scripts should work just fine.
testPathIgnorePatterns: [
'/node_modules/',
'exercise\\.js$',
'final\\.js$',
'extra-\\d+\\.js$',
],
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',
'!<rootDir>/node_modules/**/*',
'!<rootDir>/src/test/**/*',
'!<rootDir>/src/setupProxy*',
'!<rootDir>/src/setupTests*',
'!<rootDir>/src/dev-tools/**/*',
],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
}