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 } */
module.exports = {
collectCoverage: false,
globals: {
'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,
testEnvironment: 'node',
testRegex: ['.+\\.test\\.tsx?$'],
transform: { '^.+\\.tsx?$': 'ts-jest' },
verbose: false,
};

View File

@ -1,35 +1,29 @@
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
// preset: '../../jest-preset.js', // DOES NOT WORK
// same as preset:
collectCoverage: false,
globals: {
'ts-jest': {
isolatedModules: true,
},
},
testEnvironment: 'jsdom',
cache: false,
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
verbose: true,
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
resetMocks: true,
resetModules: true,
testRegex: ['.+\\.test\\.tsx?$'],
collectCoverage: false,
collectCoverageFrom: ['app/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
setupFiles: [
'./__jest__/setup.ts',
],
setupFilesAfterEnv: [
'./__jest__/setup-after-env.ts',
],
transform: { '^.+\\.tsx?$': 'ts-jest' },
// extended from preset:
cache: false,
modulePathIgnorePatterns: ['<rootDir>/network/.*/__mocks__'],
rootDir: 'app',
setupFiles: ['./__jest__/setup.ts'],
setupFilesAfterEnv: ['./__jest__/setup-after-env.ts'],
testEnvironment: 'jsdom',
verbose: true,
moduleNameMapper: {
'\\.(css|less|png)$': '<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",
"scripts": {
"clean": "tsc --build tsconfig.webpack.json --clean && tsc --build tsconfig.build.json --clean",
"test": "npm run test:jest",
"test:jest": "cross-env NODE_ENV=test jest --silent",
"test": "jest",
"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: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 } */
module.exports = {
globals: {
'ts-jest': {
isolatedModules: true,
},
},
testEnvironment: 'jsdom',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
preset: '../../jest-preset.js',
setupFilesAfterEnv: ['./src/jest/setup-after-env.ts'],
verbose: false,
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'],
testEnvironment: 'jsdom',
};

View File

@ -1,17 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
globals: {
'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'],
preset: '../../jest-preset.js',
};

View File

@ -1,17 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
globals: {
'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'],
preset: '../../jest-preset.js',
};

View File

@ -1,29 +1,8 @@
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
globals: {
'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',
],
preset: '../../jest-preset.js',
collectCoverage: true,
coveragePathIgnorePatterns: [
'/node_modules/',
],
coveragePathIgnorePatterns: ['/node_modules/'],
coverageThreshold: {
global: {
branches: 88,
@ -32,4 +11,5 @@ module.exports = {
statements: 95,
},
},
setupFiles: ['./src/jest/setup.ts'],
};

View File

@ -1,17 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
globals: {
'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'],
preset: '../../jest-preset.js',
};

View File

@ -1,20 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
globals: {
'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,
preset: '../../jest-preset.js',
};

View File

@ -1,17 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
globals: {
'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'],
preset: '../../jest-preset.js',
};

View File

@ -1,17 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
globals: {
'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'],
preset: '../../jest-preset.js',
};

View File

@ -1,19 +1,4 @@
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
globals: {
'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'],
preset: '../../jest-preset.js',
};

View File

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