-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
jest.base.config.js
34 lines (33 loc) · 1.03 KB
/
jest.base.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
const fs = require("fs")
const path = require("path")
module.exports = function buildConfig(
packageDirectory,
pkgConfig,
tsConfig = "tsconfig.test.json"
) {
const packageName = require(`${packageDirectory}/package.json`).name
const packageTsconfig = path.resolve(packageDirectory, tsConfig)
return {
preset: "ts-jest/presets/js-with-ts",
testEnvironment: "jsdom",
globals: {
__DEV__: true
},
transform: {
"^.+\\.[jt]sx?$": [
"ts-jest",
{
tsconfig: fs.existsSync(packageTsconfig)
? packageTsconfig
: path.resolve(__dirname, tsConfig)
}
]
},
testRegex: "__tests__/.*\\.(j|t)sx?$",
coverageDirectory: "<rootDir>/coverage/",
coverageReporters: ["lcov", "text"],
collectCoverageFrom: ["<rootDir>/src/**/*.{ts,tsx}", "!**/node_modules/**"],
displayName: packageName,
...pkgConfig
}
}