From e2d45ce1887f3d75f8e812478468f469067fa913 Mon Sep 17 00:00:00 2001 From: Matthew Heroux Date: Sat, 4 Nov 2023 20:56:55 -0500 Subject: [PATCH] feat: scope jest ignores (#496) Signed-off-by: hxtree --- libraries/faker-factory/jest.config.js | 15 --------------- libraries/faker-factory/jest.config.json | 12 ++++++++++++ libraries/messaging-schemas/jest.config.js | 15 --------------- libraries/messaging-schemas/jest.config.json | 12 ++++++++++++ libraries/nestjs-modules/jest.config.js | 13 ------------- libraries/nestjs-modules/jest.config.json | 12 ++++++++++++ libraries/validation-schemas/jest.config.js | 15 --------------- libraries/validation-schemas/jest.config.json | 12 ++++++++++++ .../profiles/construct/config/jest.config.json | 2 +- .../base-nodejs/profiles/library/jest.config.json | 2 +- .../profiles/nestjs-app/jest.config.json | 13 +++++++++---- .../profiles/platform-src-stack/jest.config.json | 2 +- .../profiles/platform-src/jest.config.json | 2 +- .../profiles/platform-stack/jest.config.json | 2 +- .../profiles/react-app/jest.config.json | 10 +++++++++- services/admin-client/jest.config.js | 3 ++- 16 files changed, 73 insertions(+), 69 deletions(-) delete mode 100644 libraries/faker-factory/jest.config.js create mode 100644 libraries/faker-factory/jest.config.json delete mode 100644 libraries/messaging-schemas/jest.config.js create mode 100644 libraries/messaging-schemas/jest.config.json delete mode 100644 libraries/nestjs-modules/jest.config.js create mode 100644 libraries/nestjs-modules/jest.config.json delete mode 100644 libraries/validation-schemas/jest.config.js create mode 100644 libraries/validation-schemas/jest.config.json diff --git a/libraries/faker-factory/jest.config.js b/libraries/faker-factory/jest.config.js deleted file mode 100644 index 2f721d40..00000000 --- a/libraries/faker-factory/jest.config.js +++ /dev/null @@ -1,15 +0,0 @@ -/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ -module.exports = { - preset: 'ts-jest', - testEnvironment: 'node', - collectCoverageFrom: ['**/*.{ts,tsx}', '!**/node_modules/**'], - coverageReporters: [ - 'clover', - 'json', - 'lcov', - 'html', - ['text', { skipFull: true }], - ], - testMatch: ['/src/**/*.test.ts'], - coverageDirectory: '/coverage', -}; diff --git a/libraries/faker-factory/jest.config.json b/libraries/faker-factory/jest.config.json new file mode 100644 index 00000000..b889972d --- /dev/null +++ b/libraries/faker-factory/jest.config.json @@ -0,0 +1,12 @@ +{ + "roots": ["/src/"], + "testMatch": ["/src/**/*.test.ts"], + "testPathIgnorePatterns": ["/node_modules/"], + "transform": { + "^.+\\.tsx?$": "ts-jest" + }, + "collectCoverageFrom": ["/src/*.ts"], + "coverageReporters": ["json", "text-summary"], + "coveragePathIgnorePatterns": ["index.ts"], + "coverageDirectory": "/coverage" +} diff --git a/libraries/messaging-schemas/jest.config.js b/libraries/messaging-schemas/jest.config.js deleted file mode 100644 index 2f721d40..00000000 --- a/libraries/messaging-schemas/jest.config.js +++ /dev/null @@ -1,15 +0,0 @@ -/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ -module.exports = { - preset: 'ts-jest', - testEnvironment: 'node', - collectCoverageFrom: ['**/*.{ts,tsx}', '!**/node_modules/**'], - coverageReporters: [ - 'clover', - 'json', - 'lcov', - 'html', - ['text', { skipFull: true }], - ], - testMatch: ['/src/**/*.test.ts'], - coverageDirectory: '/coverage', -}; diff --git a/libraries/messaging-schemas/jest.config.json b/libraries/messaging-schemas/jest.config.json new file mode 100644 index 00000000..b889972d --- /dev/null +++ b/libraries/messaging-schemas/jest.config.json @@ -0,0 +1,12 @@ +{ + "roots": ["/src/"], + "testMatch": ["/src/**/*.test.ts"], + "testPathIgnorePatterns": ["/node_modules/"], + "transform": { + "^.+\\.tsx?$": "ts-jest" + }, + "collectCoverageFrom": ["/src/*.ts"], + "coverageReporters": ["json", "text-summary"], + "coveragePathIgnorePatterns": ["index.ts"], + "coverageDirectory": "/coverage" +} diff --git a/libraries/nestjs-modules/jest.config.js b/libraries/nestjs-modules/jest.config.js deleted file mode 100644 index 13336847..00000000 --- a/libraries/nestjs-modules/jest.config.js +++ /dev/null @@ -1,13 +0,0 @@ -const { defaults: tsjPreset } = require('ts-jest/presets'); - -module.exports = { - transform: tsjPreset.transform, - rootDir: './src', - roots: [''], - moduleFileExtensions: ['ts', 'js', 'json', 'node'], - preset: '@shelf/jest-mongodb', - testEnvironment: 'node', - collectCoverageFrom: ['**/*.{ts,tsx}', '!**/node_modules/**'], - testMatch: ['/**/*.test.ts'], - coverageDirectory: '/coverage', -}; diff --git a/libraries/nestjs-modules/jest.config.json b/libraries/nestjs-modules/jest.config.json new file mode 100644 index 00000000..b889972d --- /dev/null +++ b/libraries/nestjs-modules/jest.config.json @@ -0,0 +1,12 @@ +{ + "roots": ["/src/"], + "testMatch": ["/src/**/*.test.ts"], + "testPathIgnorePatterns": ["/node_modules/"], + "transform": { + "^.+\\.tsx?$": "ts-jest" + }, + "collectCoverageFrom": ["/src/*.ts"], + "coverageReporters": ["json", "text-summary"], + "coveragePathIgnorePatterns": ["index.ts"], + "coverageDirectory": "/coverage" +} diff --git a/libraries/validation-schemas/jest.config.js b/libraries/validation-schemas/jest.config.js deleted file mode 100644 index 2f721d40..00000000 --- a/libraries/validation-schemas/jest.config.js +++ /dev/null @@ -1,15 +0,0 @@ -/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ -module.exports = { - preset: 'ts-jest', - testEnvironment: 'node', - collectCoverageFrom: ['**/*.{ts,tsx}', '!**/node_modules/**'], - coverageReporters: [ - 'clover', - 'json', - 'lcov', - 'html', - ['text', { skipFull: true }], - ], - testMatch: ['/src/**/*.test.ts'], - coverageDirectory: '/coverage', -}; diff --git a/libraries/validation-schemas/jest.config.json b/libraries/validation-schemas/jest.config.json new file mode 100644 index 00000000..b889972d --- /dev/null +++ b/libraries/validation-schemas/jest.config.json @@ -0,0 +1,12 @@ +{ + "roots": ["/src/"], + "testMatch": ["/src/**/*.test.ts"], + "testPathIgnorePatterns": ["/node_modules/"], + "transform": { + "^.+\\.tsx?$": "ts-jest" + }, + "collectCoverageFrom": ["/src/*.ts"], + "coverageReporters": ["json", "text-summary"], + "coveragePathIgnorePatterns": ["index.ts"], + "coverageDirectory": "/coverage" +} diff --git a/platform/rigs/base-nodejs/profiles/construct/config/jest.config.json b/platform/rigs/base-nodejs/profiles/construct/config/jest.config.json index 3b8d5a16..6305883c 100644 --- a/platform/rigs/base-nodejs/profiles/construct/config/jest.config.json +++ b/platform/rigs/base-nodejs/profiles/construct/config/jest.config.json @@ -7,6 +7,6 @@ }, "collectCoverageFrom": ["/src/*.ts", "!/src/index.ts"], "coverageReporters": ["json", "text-summary"], - "coveragePathIgnorePatterns": ["/node_modules/", "/cdk.out/", "/dist/"], + "coveragePathIgnorePatterns": ["main.ts", "app.ts", "index.ts", "/data/"], "coverageDirectory": "/coverage" } diff --git a/platform/rigs/base-nodejs/profiles/library/jest.config.json b/platform/rigs/base-nodejs/profiles/library/jest.config.json index 3b8d5a16..6305883c 100644 --- a/platform/rigs/base-nodejs/profiles/library/jest.config.json +++ b/platform/rigs/base-nodejs/profiles/library/jest.config.json @@ -7,6 +7,6 @@ }, "collectCoverageFrom": ["/src/*.ts", "!/src/index.ts"], "coverageReporters": ["json", "text-summary"], - "coveragePathIgnorePatterns": ["/node_modules/", "/cdk.out/", "/dist/"], + "coveragePathIgnorePatterns": ["main.ts", "app.ts", "index.ts", "/data/"], "coverageDirectory": "/coverage" } diff --git a/platform/rigs/base-nodejs/profiles/nestjs-app/jest.config.json b/platform/rigs/base-nodejs/profiles/nestjs-app/jest.config.json index 451c85b0..47c72180 100644 --- a/platform/rigs/base-nodejs/profiles/nestjs-app/jest.config.json +++ b/platform/rigs/base-nodejs/profiles/nestjs-app/jest.config.json @@ -2,6 +2,7 @@ "roots": ["/src/", "/stacks/"], "testMatch": [ "/src/**/*.{test,e2e-spec}.ts", + "/src/__tests__/**/*.test.ts", "/stacks/**/*.test.ts" ], "testPathIgnorePatterns": ["/node_modules/"], @@ -9,11 +10,15 @@ "^.+\\.tsx?$": "ts-jest" }, "collectCoverageFrom": [ - "/src/*.ts", - "/stacks/*.ts", - "!/src/index.ts" + "/src/**/*.ts", + "/stacks/**/*.ts", + "!/src/index.ts", + "!/src/**/*.module.ts", + "!/src/main.ts", + "!/src/app.ts", + "!/src/**/index.ts", + "!/src/**/data/**" ], "coverageReporters": ["json", "text-summary"], - "coveragePathIgnorePatterns": ["/node_modules/", "/cdk.out/", "/dist/"], "coverageDirectory": "/coverage" } diff --git a/platform/rigs/base-nodejs/profiles/platform-src-stack/jest.config.json b/platform/rigs/base-nodejs/profiles/platform-src-stack/jest.config.json index 17e0318a..884367f7 100644 --- a/platform/rigs/base-nodejs/profiles/platform-src-stack/jest.config.json +++ b/platform/rigs/base-nodejs/profiles/platform-src-stack/jest.config.json @@ -15,6 +15,6 @@ "!/stacks/**/index.ts" ], "coverageReporters": ["json", "text-summary"], - "coveragePathIgnorePatterns": ["/node_modules/", "/cdk.out/", "/dist/"], + "coveragePathIgnorePatterns": ["main.ts", "app.ts", "index.ts", "/data/"], "coverageDirectory": "/coverage" } diff --git a/platform/rigs/base-nodejs/profiles/platform-src/jest.config.json b/platform/rigs/base-nodejs/profiles/platform-src/jest.config.json index 7c9f2645..871de07e 100644 --- a/platform/rigs/base-nodejs/profiles/platform-src/jest.config.json +++ b/platform/rigs/base-nodejs/profiles/platform-src/jest.config.json @@ -7,6 +7,6 @@ }, "collectCoverageFrom": ["/src/*.ts", "!/src/**/index.ts"], "coverageReporters": ["json", "text-summary"], - "coveragePathIgnorePatterns": ["/node_modules/", "/cdk.out/", "/dist/"], + "coveragePathIgnorePatterns": ["main.ts", "app.ts", "index.ts", "/data/"], "coverageDirectory": "/coverage" } diff --git a/platform/rigs/base-nodejs/profiles/platform-stack/jest.config.json b/platform/rigs/base-nodejs/profiles/platform-stack/jest.config.json index 576bdf50..6e225b29 100644 --- a/platform/rigs/base-nodejs/profiles/platform-stack/jest.config.json +++ b/platform/rigs/base-nodejs/profiles/platform-stack/jest.config.json @@ -10,6 +10,6 @@ "!/stacks/**/index.ts" ], "coverageReporters": ["json", "text-summary"], - "coveragePathIgnorePatterns": ["/node_modules/", "/cdk.out/", "/dist/"], + "coveragePathIgnorePatterns": ["main.ts", "app.ts", "index.ts", "/data/"], "coverageDirectory": "/coverage" } diff --git a/platform/rigs/base-nodejs/profiles/react-app/jest.config.json b/platform/rigs/base-nodejs/profiles/react-app/jest.config.json index 84c7acef..ccc300e9 100644 --- a/platform/rigs/base-nodejs/profiles/react-app/jest.config.json +++ b/platform/rigs/base-nodejs/profiles/react-app/jest.config.json @@ -8,6 +8,14 @@ "collectCoverage": true, "collectCoverageFrom": ["/src/**/*.{ts,tsx}"], "coverageReporters": ["text-summary", "clover"], - "coveragePathIgnorePatterns": ["/node_modules/", "/cdk.out/", "/dist/"], + "coveragePathIgnorePatterns": [ + "/**/main.ts", + "/**/app.ts", + "/**/index.ts", + "/**/data/", + "/node_modules/", + "/cdk.out/", + "/dist/" + ], "coverageDirectory": "/src/__tests__/coverage" } diff --git a/services/admin-client/jest.config.js b/services/admin-client/jest.config.js index 4cafc1da..0d42ce93 100644 --- a/services/admin-client/jest.config.js +++ b/services/admin-client/jest.config.js @@ -3,13 +3,14 @@ module.exports = { // on node 14.x coverage provider v8 offers good speed and more or less good report coverageProvider: 'v8', collectCoverageFrom: [ - '**/*.{js,jsx,ts,tsx}', + 'components/**/*.{js,jsx,ts,tsx}', '!**/*.d.ts', '!**/node_modules/**', '!/out/**', '!/.next/**', '!/*.config.js', '!/coverage/**', + '!/pages/**', ], moduleNameMapper: { // Handle CSS imports (with CSS modules)