From 2225bbd6ea99093a6f59a18571ccde4852ccf74b Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Thu, 19 Nov 2020 15:50:32 +0100 Subject: [PATCH 1/4] collect code coverage for more files in src/ --- src/dev/jest/config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index 9f445b0c05be9..2dc2bd47bd8f5 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -39,6 +39,9 @@ export default { '/src/dev/code_coverage/ingest_coverage', ], collectCoverageFrom: [ + 'src/{cli,cli_keystore,cli_plugin,core}/**/*.{ts,tsx}', + '!src/{cli,cli_keystore,cli_plugin,core}/**/{test_helpers,__snapshots__,mocks,tests}/**/*', + '!src/{cli,cli_keystore,cli_plugin,core}/**/*.{test, mock}.ts', 'src/plugins/**/*.{ts,tsx}', '!src/plugins/**/{__test__,__snapshots__,__examples__,mocks,tests}/**/*', '!src/plugins/**/*.d.ts', From ba57c751b99d2b9e4f33d8cb5c74dd794dce0933 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Thu, 19 Nov 2020 16:59:58 +0100 Subject: [PATCH 2/4] update config --- src/dev/jest/config.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index 2dc2bd47bd8f5..2890ec95429b5 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -40,8 +40,9 @@ export default { ], collectCoverageFrom: [ 'src/{cli,cli_keystore,cli_plugin,core}/**/*.{ts,tsx}', - '!src/{cli,cli_keystore,cli_plugin,core}/**/{test_helpers,__snapshots__,mocks,tests}/**/*', - '!src/{cli,cli_keystore,cli_plugin,core}/**/*.{test, mock}.ts', + '!src/**/{test_helpers,__snapshots__,mocks,integration_tests,tests}/**/*', + '!src/**/*mock*.ts', + '!src/**/*.test.ts', 'src/plugins/**/*.{ts,tsx}', '!src/plugins/**/{__test__,__snapshots__,__examples__,mocks,tests}/**/*', '!src/plugins/**/*.d.ts', From 379d8c0ecaf7235b7f08e8c74c778cbf4f98115a Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Fri, 20 Nov 2020 18:45:56 +0100 Subject: [PATCH 3/4] update config according review --- src/dev/jest/config.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index 2890ec95429b5..bf7ba25ff0acb 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -39,20 +39,12 @@ export default { '/src/dev/code_coverage/ingest_coverage', ], collectCoverageFrom: [ - 'src/{cli,cli_keystore,cli_plugin,core}/**/*.{ts,tsx}', - '!src/**/{test_helpers,__snapshots__,mocks,integration_tests,tests}/**/*', - '!src/**/*mock*.ts', - '!src/**/*.test.ts', - 'src/plugins/**/*.{ts,tsx}', - '!src/plugins/**/{__test__,__snapshots__,__examples__,mocks,tests}/**/*', - '!src/plugins/**/*.d.ts', - '!src/plugins/**/test_helpers/**', - 'packages/kbn-ui-framework/src/components/**/*.js', - '!packages/kbn-ui-framework/src/components/index.js', - '!packages/kbn-ui-framework/src/components/**/*/index.js', - 'packages/kbn-ui-framework/src/services/**/*.js', - '!packages/kbn-ui-framework/src/services/index.js', - '!packages/kbn-ui-framework/src/services/**/*/index.js', + '**/*.{js,mjs,jsx,ts,tsx}', + '!**/{__test__,__snapshots__,__examples__,mocks,tests,test_helpers,integration_tests,types}/**/*', + '!**/*mock*.ts', + '!**/*.test.ts', + '!**/*.d.ts', + '!**/index.{js,ts}', ], testRunner: 'jasmine2', }; From 9e7d7f715eb49bedc72b4253b6fbbb7ea365d42f Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Fri, 20 Nov 2020 19:24:46 +0100 Subject: [PATCH 4/4] move collectCoverageFrom to preset --- packages/kbn-test/jest-preset.js | 10 ++++++++++ src/dev/jest/config.js | 8 -------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/kbn-test/jest-preset.js b/packages/kbn-test/jest-preset.js index 4a85eca206c96..f899a5b44ab6c 100644 --- a/packages/kbn-test/jest-preset.js +++ b/packages/kbn-test/jest-preset.js @@ -108,4 +108,14 @@ module.exports = { '[/\\\\]node_modules(?![\\/\\\\]monaco-editor)[/\\\\].+\\.js$', 'packages/kbn-pm/dist/index.js', ], + + // An array of regexp pattern strings that are matched against all source file paths, matched files to include/exclude for code coverage + collectCoverageFrom: [ + '**/*.{js,mjs,jsx,ts,tsx}', + '!**/{__test__,__snapshots__,__examples__,mocks,tests,test_helpers,integration_tests,types}/**/*', + '!**/*mock*.ts', + '!**/*.test.ts', + '!**/*.d.ts', + '!**/index.{js,ts}', + ], }; diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index 20d613997b6b3..93d7218b11c28 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -39,13 +39,5 @@ export default { '/test/functional/services/remote', '/src/dev/code_coverage/ingest_coverage', ], - collectCoverageFrom: [ - '**/*.{js,mjs,jsx,ts,tsx}', - '!**/{__test__,__snapshots__,__examples__,mocks,tests,test_helpers,integration_tests,types}/**/*', - '!**/*mock*.ts', - '!**/*.test.ts', - '!**/*.d.ts', - '!**/index.{js,ts}', - ], testRunner: 'jasmine2', };