-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
40 lines (38 loc) · 1.71 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
// IMPORTANT: https://www.typescriptlang.org/tsconfig#esModuleInterop
// "esModuleInterop" should be set to TRUE in tsconfig.json
module.exports = {
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: "es2019",
},
},
},
// 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: {
// This one will require babel config and additional babel deps.
// "^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": "ts-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>/src/__mocks__/file-mock.ts`,
},
// Tells Jest what folders to ignore for tests
// testPathIgnorePatterns: [`node_modules`, `\\.cache`],
// IMPORTANT: it's vital to have exactly "setupFilesAfterEnv"
setupFilesAfterEnv: ["<rootDir>/src/setupTests.ts"],
};