generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
jest.typescript.config.js
30 lines (27 loc) · 759 Bytes
/
jest.typescript.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
const { jsWithTs } = require("ts-jest/presets");
const baseConfig = require("./jest.config");
const baseTsConfig = {
...baseConfig,
...jsWithTs,
preset: "ts-jest",
transform: {
"^.+\\.(ts|tsx)?": ["ts-jest", { isolatedModules: true }],
},
testEnvironment: "jsdom",
};
const generateConfig = ({ collectCoverageFrom = [], moduleNameMapper = {}, rootDir = ".", tsconfig = {} }) => ({
...baseTsConfig,
collectCoverageFrom: [...baseTsConfig.collectCoverageFrom, ...collectCoverageFrom],
moduleNameMapper: {
...baseTsConfig.moduleNameMapper,
...moduleNameMapper,
},
rootDir,
transform: {
"^.+\\.(ts|tsx)?": ["ts-jest", { isolatedModules: true, tsconfig }],
},
});
module.exports = {
baseTsConfig,
generateConfig,
};