Share the same tsconfig by adding overrides in new jest config

This commit is contained in:
Jakub Okoński 2019-10-18 16:02:53 +02:00
parent ecd3a218aa
commit 8030143ace
4 changed files with 28 additions and 51 deletions

27
jest.config.js Normal file
View file

@ -0,0 +1,27 @@
const tsConfig = require('./tsconfig');
module.exports = {
preset: "ts-jest",
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
globals: {
"ts-jest": {
tsConfig: {
...tsConfig.compilerOptions,
types: ["jest", "node"]
},
diagnostics: {
ignoreCodes: [151001]
},
}
},
moduleNameMapper: {
"@src/(.*)": "<rootDir>/src/$1"
},
moduleFileExtensions: [
"ts",
"tsx",
"js",
"jsx",
"json"
],
};

View file

@ -58,30 +58,6 @@
"lint": "bash hooks/pre-commit",
"pretty": "bash scripts/pretty.sh"
},
"jest": {
"preset": "ts-jest",
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
],
"moduleNameMapper": {
"@src/(.*)": "<rootDir>/src/$1"
},
"globals": {
"ts-jest": {
"tsConfig": "tsconfig.test.json",
"diagnostics": {
"ignoreCodes": [
151001
]
}
}
}
},
"author": "Colin Caine",
"repository": {
"type": "git",

View file

@ -6,7 +6,7 @@
"outDir": "build/tsc-out",
"sourceMap": true,
"target": "es2017",
"lib": ["es2017","es2019.array","dom", "dom.iterable"],
"lib": ["es2017","es2019.array", "es2018.promise", "dom", "dom.iterable"],
"types": ["web-ext-types"],
"experimentalDecorators": true,
"alwaysStrict": true,

View file

@ -1,26 +0,0 @@
{
"compilerOptions": {
"allowJs": true,
"moduleResolution": "node",
"noImplicitAny": false,
"noEmitOnError": true,
"outDir": "build/tsc-out",
"sourceMap": true,
"target": "es2017",
"lib": ["es2017", "es2019.array", "es2018.promise", "dom", "dom.iterable"],
"typeRoots": ["node_modules/@types"],
"types": ["jest", "node"],
"experimentalDecorators": true,
"alwaysStrict": true,
"baseUrl": "src/",
"paths": {
"@src/*": ["*"]
}
},
"include": [
"./src/**/*"
],
"exclude": [
"./src/**/*.test.ts"
]
}