From 5fcc5d493bbfd402b0e6a5d2aad27da4b1a471a2 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Wed, 4 Mar 2020 22:36:43 +0100 Subject: [PATCH] chore: reuse jest config --- jest/config.js | 9 +++++++++ packages/api/jest.config.js | 12 +++--------- packages/auth/jest.config.js | 12 +++--------- packages/cli/jest.config.js | 12 +++--------- packages/config/jest.config.js | 12 +++--------- packages/hooks/jest.config.js | 12 +++--------- packages/loaders/jest.config.js | 13 +++++-------- packages/loaders/tsconfig.json | 3 ++- packages/logger/jest.config.js | 15 ++++++--------- packages/logger/src/logger.ts | 1 - packages/logger/tsconfig.json | 3 ++- packages/middleware/jest.config.js | 6 ++++++ packages/mock/jest.config.js | 15 ++++++--------- packages/node-api/jest.config.js | 15 ++++++--------- packages/proxy/jest.config.js | 15 ++++++--------- packages/server/jest.config.js | 12 +++++------- packages/server/tsconfig.json | 3 ++- packages/store/jest.config.js | 12 +++++------- packages/utils/jest.config.js | 13 +++++-------- packages/utils/tsconfig.json | 3 ++- 20 files changed, 82 insertions(+), 116 deletions(-) create mode 100644 jest/config.js create mode 100644 packages/middleware/jest.config.js diff --git a/jest/config.js b/jest/config.js new file mode 100644 index 000000000..45146c37f --- /dev/null +++ b/jest/config.js @@ -0,0 +1,9 @@ +module.exports = { + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + transform: { + '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', + }, + verbose: true, + collectCoverage: true, + coveragePathIgnorePatterns: ['node_modules', 'fixtures'], +}; diff --git a/packages/api/jest.config.js b/packages/api/jest.config.js index 45146c37f..7da7d2da8 100644 --- a/packages/api/jest.config.js +++ b/packages/api/jest.config.js @@ -1,9 +1,3 @@ -module.exports = { - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', - }, - verbose: true, - collectCoverage: true, - coveragePathIgnorePatterns: ['node_modules', 'fixtures'], -}; +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, {}); diff --git a/packages/auth/jest.config.js b/packages/auth/jest.config.js index 45146c37f..7da7d2da8 100644 --- a/packages/auth/jest.config.js +++ b/packages/auth/jest.config.js @@ -1,9 +1,3 @@ -module.exports = { - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', - }, - verbose: true, - collectCoverage: true, - coveragePathIgnorePatterns: ['node_modules', 'fixtures'], -}; +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, {}); diff --git a/packages/cli/jest.config.js b/packages/cli/jest.config.js index 45146c37f..7da7d2da8 100644 --- a/packages/cli/jest.config.js +++ b/packages/cli/jest.config.js @@ -1,9 +1,3 @@ -module.exports = { - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', - }, - verbose: true, - collectCoverage: true, - coveragePathIgnorePatterns: ['node_modules', 'fixtures'], -}; +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, {}); diff --git a/packages/config/jest.config.js b/packages/config/jest.config.js index 45146c37f..7da7d2da8 100644 --- a/packages/config/jest.config.js +++ b/packages/config/jest.config.js @@ -1,9 +1,3 @@ -module.exports = { - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', - }, - verbose: true, - collectCoverage: true, - coveragePathIgnorePatterns: ['node_modules', 'fixtures'], -}; +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, {}); diff --git a/packages/hooks/jest.config.js b/packages/hooks/jest.config.js index 45146c37f..7da7d2da8 100644 --- a/packages/hooks/jest.config.js +++ b/packages/hooks/jest.config.js @@ -1,9 +1,3 @@ -module.exports = { - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', - }, - verbose: true, - collectCoverage: true, - coveragePathIgnorePatterns: ['node_modules', 'fixtures'], -}; +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, {}); diff --git a/packages/loaders/jest.config.js b/packages/loaders/jest.config.js index b8eccba20..91554a23b 100644 --- a/packages/loaders/jest.config.js +++ b/packages/loaders/jest.config.js @@ -1,9 +1,6 @@ -module.exports = { - moduleFileExtensions: ['ts', 'js'], - transform: { - '^.+\\.(js|ts)$': 'babel-jest', - }, - verbose: true, - // FIXME: the coverage returns an error here +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, { collectCoverage: false -}; +}); + diff --git a/packages/loaders/tsconfig.json b/packages/loaders/tsconfig.json index 6531bd3e4..a9539c625 100644 --- a/packages/loaders/tsconfig.json +++ b/packages/loaders/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig", "compilerOptions": { "rootDir": "./src", - "outDir": "./build" + "outDir": "./build", + "allowSyntheticDefaultImports": true }, "include": ["src/**/*"], "exclude": ["src/**/*.test.ts"] diff --git a/packages/logger/jest.config.js b/packages/logger/jest.config.js index 9c48852a3..91554a23b 100644 --- a/packages/logger/jest.config.js +++ b/packages/logger/jest.config.js @@ -1,9 +1,6 @@ -module.exports = { - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', - }, - verbose: true, - collectCoverage: false, - coveragePathIgnorePatterns: ['node_modules', 'fixtures'], -}; +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, { + collectCoverage: false +}); + diff --git a/packages/logger/src/logger.ts b/packages/logger/src/logger.ts index bece6ca6a..c64d9e80d 100644 --- a/packages/logger/src/logger.ts +++ b/packages/logger/src/logger.ts @@ -5,7 +5,6 @@ const Logger = require('bunyan'); const Error = require('http-errors'); const Stream = require('stream'); const _ = require('lodash'); -const dayjs = require('dayjs'); const pkgJSON = require('../package.json'); diff --git a/packages/logger/tsconfig.json b/packages/logger/tsconfig.json index 6531bd3e4..a9539c625 100644 --- a/packages/logger/tsconfig.json +++ b/packages/logger/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig", "compilerOptions": { "rootDir": "./src", - "outDir": "./build" + "outDir": "./build", + "allowSyntheticDefaultImports": true }, "include": ["src/**/*"], "exclude": ["src/**/*.test.ts"] diff --git a/packages/middleware/jest.config.js b/packages/middleware/jest.config.js new file mode 100644 index 000000000..535d72654 --- /dev/null +++ b/packages/middleware/jest.config.js @@ -0,0 +1,6 @@ +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, { + collectCoverage: true +}); + diff --git a/packages/mock/jest.config.js b/packages/mock/jest.config.js index 45146c37f..535d72654 100644 --- a/packages/mock/jest.config.js +++ b/packages/mock/jest.config.js @@ -1,9 +1,6 @@ -module.exports = { - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', - }, - verbose: true, - collectCoverage: true, - coveragePathIgnorePatterns: ['node_modules', 'fixtures'], -}; +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, { + collectCoverage: true +}); + diff --git a/packages/node-api/jest.config.js b/packages/node-api/jest.config.js index 45146c37f..535d72654 100644 --- a/packages/node-api/jest.config.js +++ b/packages/node-api/jest.config.js @@ -1,9 +1,6 @@ -module.exports = { - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', - }, - verbose: true, - collectCoverage: true, - coveragePathIgnorePatterns: ['node_modules', 'fixtures'], -}; +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, { + collectCoverage: true +}); + diff --git a/packages/proxy/jest.config.js b/packages/proxy/jest.config.js index 45146c37f..535d72654 100644 --- a/packages/proxy/jest.config.js +++ b/packages/proxy/jest.config.js @@ -1,9 +1,6 @@ -module.exports = { - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', - }, - verbose: true, - collectCoverage: true, - coveragePathIgnorePatterns: ['node_modules', 'fixtures'], -}; +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, { + collectCoverage: true +}); + diff --git a/packages/server/jest.config.js b/packages/server/jest.config.js index ba98cff55..4a38b60b3 100644 --- a/packages/server/jest.config.js +++ b/packages/server/jest.config.js @@ -1,10 +1,8 @@ -module.exports = { - moduleFileExtensions: ['ts', 'js'], - transform: { - '^.+\\.(js|ts)$': 'babel-jest', - }, - verbose: true, +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, { setupFilesAfterEnv: ['./jest.setup.js'], // FIXME: coverage fails here collectCoverage: false -}; +}); + diff --git a/packages/server/tsconfig.json b/packages/server/tsconfig.json index 2be65b934..0cedf65b8 100644 --- a/packages/server/tsconfig.json +++ b/packages/server/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig", "compilerOptions": { "rootDir": "./src", - "outDir": "./build" + "outDir": "./build", + "allowSyntheticDefaultImports": true }, "include": ["src/**/*", "types/*.d.ts"], "exclude": ["src/**/*.test.ts"] diff --git a/packages/store/jest.config.js b/packages/store/jest.config.js index d639ba9fc..61d0f61e0 100644 --- a/packages/store/jest.config.js +++ b/packages/store/jest.config.js @@ -1,9 +1,7 @@ -module.exports = { - moduleFileExtensions: ['ts', 'js'], - transform: { - '^.+\\.(js|ts)$': 'babel-jest', - }, - verbose: true, +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, { // FIXME: coverage fails here collectCoverage: false -}; +}); + diff --git a/packages/utils/jest.config.js b/packages/utils/jest.config.js index 9c48852a3..8bdede2e7 100644 --- a/packages/utils/jest.config.js +++ b/packages/utils/jest.config.js @@ -1,9 +1,6 @@ -module.exports = { - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', - }, - verbose: true, - collectCoverage: false, +const config = require('../../jest/config'); + +module.exports = Object.assign({}, config, { + collectCoverage: true, coveragePathIgnorePatterns: ['node_modules', 'fixtures'], -}; +}); diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json index 6531bd3e4..a9539c625 100644 --- a/packages/utils/tsconfig.json +++ b/packages/utils/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig", "compilerOptions": { "rootDir": "./src", - "outDir": "./build" + "outDir": "./build", + "allowSyntheticDefaultImports": true }, "include": ["src/**/*"], "exclude": ["src/**/*.test.ts"]