remove duplication of all jest configs (#3375)

* use jest-preset for all but app

* separate properties that are the same as the preset

for some reason, it doesn't work.  you get:
```
Preset ../../jest-preset.js not found.
```

This needs to be investigated.

* removes unused/unneeded npm script in `app`, `test:jest`
This commit is contained in:
Dimitri Mitropoulos 2021-05-13 07:29:02 -04:00 committed by GitHub
parent 3b757251c9
commit 5fe277ee02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 33 additions and 175 deletions

View File

@ -1,20 +1,16 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
collectCoverage: false,
globals: { globals: {
'ts-jest': { 'ts-jest': {
isolatedModules: true, isolatedModules: true,
}, },
}, },
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testMatch: [
'**/*.test.ts',
],
verbose: false,
resetMocks: true, resetMocks: true,
resetModules: true, resetModules: true,
collectCoverage: false, testEnvironment: 'node',
testRegex: ['.+\\.test\\.tsx?$'],
transform: { '^.+\\.tsx?$': 'ts-jest' },
verbose: false,
}; };

View File

@ -1,35 +1,29 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
// preset: '../../jest-preset.js', // DOES NOT WORK
// same as preset:
collectCoverage: false,
globals: { globals: {
'ts-jest': { 'ts-jest': {
isolatedModules: true, isolatedModules: true,
}, },
}, },
testEnvironment: 'jsdom', moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
cache: false,
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
verbose: true,
resetMocks: true, resetMocks: true,
resetModules: true, resetModules: true,
testRegex: ['.+\\.test\\.tsx?$'], testRegex: ['.+\\.test\\.tsx?$'],
collectCoverage: false, transform: { '^.+\\.tsx?$': 'ts-jest' },
collectCoverageFrom: ['app/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], // extended from preset:
coverageReporters: ['text-summary', 'lcov'], cache: false,
setupFiles: [ modulePathIgnorePatterns: ['<rootDir>/network/.*/__mocks__'],
'./__jest__/setup.ts', rootDir: 'app',
], setupFiles: ['./__jest__/setup.ts'],
setupFilesAfterEnv: [ setupFilesAfterEnv: ['./__jest__/setup-after-env.ts'],
'./__jest__/setup-after-env.ts', testEnvironment: 'jsdom',
], verbose: true,
moduleNameMapper: { moduleNameMapper: {
'\\.(css|less|png)$': '<rootDir>/__mocks__/dummy.ts', '\\.(css|less|png)$': '<rootDir>/__mocks__/dummy.ts',
'^worker-loader!': '<rootDir>/__mocks__/dummy.ts', '^worker-loader!': '<rootDir>/__mocks__/dummy.ts',
}, },
modulePathIgnorePatterns: [
'<rootDir>/network/.*/__mocks__',
],
rootDir: 'app',
}; };

View File

@ -9,8 +9,7 @@
"main": "app/main.min.js", "main": "app/main.min.js",
"scripts": { "scripts": {
"clean": "tsc --build tsconfig.webpack.json --clean && tsc --build tsconfig.build.json --clean", "clean": "tsc --build tsconfig.webpack.json --clean && tsc --build tsconfig.build.json --clean",
"test": "npm run test:jest", "test": "jest",
"test:jest": "cross-env NODE_ENV=test jest --silent",
"test-appveyor": "npm run test -- --maxWorkers 1", "test-appveyor": "npm run test -- --maxWorkers 1",
"start:electron": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" cross-env NODE_ENV=development webpack --config webpack/webpack.config.electron.ts && electron .", "start:electron": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" cross-env NODE_ENV=development webpack --config webpack/webpack.config.electron.ts && electron .",
"start:dev-server": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack-dev-server --config webpack/webpack.config.development.ts", "start:dev-server": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack-dev-server --config webpack/webpack.config.development.ts",

View File

@ -1,21 +1,6 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
globals: { preset: '../../jest-preset.js',
'ts-jest': {
isolatedModules: true,
},
},
testEnvironment: 'jsdom',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
setupFilesAfterEnv: ['./src/jest/setup-after-env.ts'], setupFilesAfterEnv: ['./src/jest/setup-after-env.ts'],
verbose: false, testEnvironment: 'jsdom',
resetMocks: true,
resetModules: true,
testRegex: ['.+\\.test\\.tsx?$'],
collectCoverage: false,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
}; };

View File

@ -1,17 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
globals: { preset: '../../jest-preset.js',
'ts-jest': {
isolatedModules: true,
},
},
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: ['.+\\.test\\.ts$'],
collectCoverage: false,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
}; };

View File

@ -1,17 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
globals: { preset: '../../jest-preset.js',
'ts-jest': {
isolatedModules: true,
},
},
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: ['.+\\.test\\.ts$'],
collectCoverage: false,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
}; };

View File

@ -1,29 +1,8 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
globals: { preset: '../../jest-preset.js',
'ts-jest': {
isolatedModules: true,
},
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testMatch: [
'**/*.test.ts',
],
verbose: false,
resetMocks: true,
resetModules: true,
setupFiles: [
'./src/jest/setup.ts',
],
collectCoverage: true, collectCoverage: true,
coveragePathIgnorePatterns: [ coveragePathIgnorePatterns: ['/node_modules/'],
'/node_modules/',
],
coverageThreshold: { coverageThreshold: {
global: { global: {
branches: 88, branches: 88,
@ -32,4 +11,5 @@ module.exports = {
statements: 95, statements: 95,
}, },
}, },
setupFiles: ['./src/jest/setup.ts'],
}; };

View File

@ -1,17 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
globals: { preset: '../../jest-preset.js',
'ts-jest': {
isolatedModules: true,
},
},
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: ['.+\\.test\\.ts$'],
collectCoverage: false,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
}; };

View File

@ -1,20 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
globals: { preset: '../../jest-preset.js',
'ts-jest': {
isolatedModules: true,
},
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testMatch: [
'**/*.test.ts',
],
verbose: false,
resetMocks: true,
resetModules: true,
collectCoverage: false,
}; };

View File

@ -1,17 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
globals: { preset: '../../jest-preset.js',
'ts-jest': {
isolatedModules: true,
},
},
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: ['.+\\.test\\.ts$'],
collectCoverage: false,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
}; };

View File

@ -1,17 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
globals: { preset: '../../jest-preset.js',
'ts-jest': {
isolatedModules: true,
},
},
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: ['.+\\.test\\.ts$'],
collectCoverage: false,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
}; };

View File

@ -1,19 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */ /** @type { import('@jest/types').Config.InitialOptions } */
module.exports = { module.exports = {
globals: { preset: '../../jest-preset.js',
'ts-jest': {
isolatedModules: true,
},
},
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: ['.+\\.test\\.ts$'],
collectCoverage: false,
resetMocks: true,
resetModules: true,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
}; };

View File

@ -2,6 +2,6 @@
"extends": "./tsconfig.base.json", "extends": "./tsconfig.base.json",
"include": [ "include": [
".eslintrc.js", ".eslintrc.js",
"jest.config.js" "jest-preset.js"
] ]
} }