-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
jest.config.js
48 lines (47 loc) · 1.76 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
// import jestConfig from 'jest-config';
// const {defaults} = jestConfig;
const {defaults} = require('jest-config');
module.exports = {
roots: ['./__tests__'],
globals: {
'ts-jest': {
// Tell ts-jest about our typescript config.
// You can specify a path to your tsconfig.json file,
// but since we're compiling specifically for node here,
// this works too.
tsConfig: {
target: './tsconfig.json',
},
},
},
// Transforms tell jest how to process our non-javascript files.
// Here we're using babel for .js and .jsx files, and ts-jest for
// .ts and .tsx files. You *can* just use babel-jest for both, if
// you already have babel set up to compile typescript files.
transform: {
// '^.+\\.jsx?$': 'babel-jest',
// '^.+\\.tsx?$': 'ts-jest',
// If you're using babel for both:
'^.+\\.[jt]sx?$': 'babel-jest',
},
// In webpack projects, we often allow importing things like css files or jpg
// files, and let a webpack loader plugin take care of loading these resources.
// In a unit test, though, we're running in node.js which doesn't know how
// to import these, so this tells jest what to do for these.
moduleNameMapper: {
// Resolve .css and similar files to identity-obj-proxy instead.
'.+\\.(css|styl|less|sass|scss)$': `identity-obj-proxy`,
// Resolve .jpg and similar files to __mocks__/file-mock.js
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': `<rootDir>/__mocks__/file-mock.js`,
},
// Tells Jest what folders to ignore for tests
testPathIgnorePatterns: [`node_modules`, `\\.cache`],
testURL: `http://localhost`,
moduleFileExtensions: [
...defaults.moduleFileExtensions,
'.ts',
'.tsx',
'.js',
'.jsx',
],
};