From 4eba7d7102d32e9fb3ee907871ae66f9ea38f0d6 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Sun, 21 Aug 2022 08:45:41 +0300 Subject: [PATCH 1/3] feat!: remove collectCoverageOnlyFrom option --- docs/WatchPlugins.md | 1 - e2e/__tests__/coverageReport.test.ts | 6 +- e2e/transform/babel-jest/package.json | 8 +- e2e/transform/no-babel-jest/package.json | 8 +- e2e/transform/transformer-config/package.json | 8 +- packages/jest-cli/src/cli/args.ts | 5 -- packages/jest-config/src/Deprecated.ts | 8 ++ packages/jest-config/src/ValidConfig.ts | 3 - .../__snapshots__/normalize.test.ts.snap | 24 ++++++ .../src/__tests__/normalize.test.ts | 73 ++++--------------- .../src/__tests__/setFromArgv.test.ts | 4 +- packages/jest-config/src/index.ts | 1 - packages/jest-config/src/normalize.ts | 25 ------- .../jest-core/src/__tests__/watch.test.js | 1 - .../jest-core/src/lib/updateGlobalConfig.ts | 4 - packages/jest-core/src/watch.ts | 2 - packages/jest-phabricator/README.md | 2 +- packages/jest-repl/src/cli/runtime-cli.ts | 1 - .../src/generateEmptyCoverage.ts | 1 - packages/jest-runner/src/runTest.ts | 1 - .../src/__mocks__/createRuntime.js | 1 - .../src/__tests__/ScriptTransformer.test.ts | 1 - .../ScriptTransformer.test.ts.snap | 3 - .../src/__tests__/shouldInstrument.test.ts | 20 ----- .../jest-transform/src/shouldInstrument.ts | 10 --- packages/jest-transform/src/types.ts | 5 +- packages/jest-types/src/Config.ts | 7 -- .../src/__tests__/fixtures/jestConfig.ts | 3 - packages/jest-watcher/src/types.ts | 1 - packages/test-utils/src/config.ts | 1 - 30 files changed, 66 insertions(+), 172 deletions(-) diff --git a/docs/WatchPlugins.md b/docs/WatchPlugins.md index bcf2991083f1..a3064dd394ed 100644 --- a/docs/WatchPlugins.md +++ b/docs/WatchPlugins.md @@ -157,7 +157,6 @@ For stability and safety reasons, only part of the global configuration keys can - [`changedSince`](cli#--changedsince) - [`collectCoverage`](configuration#collectcoverage-boolean) - [`collectCoverageFrom`](configuration#collectcoveragefrom-array) -- [`collectCoverageOnlyFrom`](configuration#collectcoverageonlyfrom-array) - [`coverageDirectory`](configuration#coveragedirectory-string) - [`coverageReporters`](configuration#coveragereporters-arraystring) - [`notify`](configuration#notify-boolean) diff --git a/e2e/__tests__/coverageReport.test.ts b/e2e/__tests__/coverageReport.test.ts index f5954d002229..eceac4342f7e 100644 --- a/e2e/__tests__/coverageReport.test.ts +++ b/e2e/__tests__/coverageReport.test.ts @@ -72,7 +72,7 @@ test('collects coverage only from specified files avoiding dependencies', () => [ '--no-cache', '--coverage', - '--collectCoverageOnlyFrom', + '--collectCoverageFrom', 'sum.js', '--', 'sum.test.js', @@ -164,9 +164,9 @@ test('collects coverage from duplicate files avoiding shared cache', () => { // Ensure the exitCode is non-zero if super edge case with coverage triggers '--coverageThreshold', '{"global": {"lines": 100}}', - '--collectCoverageOnlyFrom', + '--collectCoverageFrom', 'cached-duplicates/a/identical.js', - '--collectCoverageOnlyFrom', + '--collectCoverageFrom', 'cached-duplicates/b/identical.js', '--', 'identical.test.js', diff --git a/e2e/transform/babel-jest/package.json b/e2e/transform/babel-jest/package.json index a070c4c33e01..d42d57c4e61d 100644 --- a/e2e/transform/babel-jest/package.json +++ b/e2e/transform/babel-jest/package.json @@ -3,10 +3,10 @@ "@babel/preset-flow": "^7.0.0" }, "jest": { - "collectCoverageOnlyFrom": { - "/this-directory-is-covered/covered.js": true, - "/this-directory-is-covered/excludedFromCoverage.js": true - }, + "collectCoverageFrom": [ + "/this-directory-is-covered/covered.js", + "/this-directory-is-covered/excludedFromCoverage.js" + ], "coveragePathIgnorePatterns": [ "excludedFromCoverage" ], diff --git a/e2e/transform/no-babel-jest/package.json b/e2e/transform/no-babel-jest/package.json index 16da6b6cf73c..99b8a573ee61 100644 --- a/e2e/transform/no-babel-jest/package.json +++ b/e2e/transform/no-babel-jest/package.json @@ -1,9 +1,9 @@ { "jest": { - "collectCoverageOnlyFrom": { - "/this-directory-is-covered/covered.js": true, - "/this-directory-is-covered/excludedFromCoverage.js": true - }, + "collectCoverageFrom": [ + "/this-directory-is-covered/covered.js", + "/this-directory-is-covered/excludedFromCoverage.js" + ], "coveragePathIgnorePatterns": [ "excludedFromCoverage" ], diff --git a/e2e/transform/transformer-config/package.json b/e2e/transform/transformer-config/package.json index 432c19c35461..33651435e159 100644 --- a/e2e/transform/transformer-config/package.json +++ b/e2e/transform/transformer-config/package.json @@ -4,10 +4,10 @@ "@babel/preset-flow": "^7.0.0" }, "jest": { - "collectCoverageOnlyFrom": { - "/this-directory-is-covered/Covered.js": true, - "/this-directory-is-covered/ExcludedFromCoverage.js": true - }, + "collectCoverageFrom": [ + "/this-directory-is-covered/Covered.js", + "/this-directory-is-covered/ExcludedFromCoverage.js" + ], "coveragePathIgnorePatterns": [ "ExcludedFromCoverage" ], diff --git a/packages/jest-cli/src/cli/args.ts b/packages/jest-cli/src/cli/args.ts index eee274a77e85..f58194047977 100644 --- a/packages/jest-cli/src/cli/args.ts +++ b/packages/jest-cli/src/cli/args.ts @@ -176,11 +176,6 @@ export const options: {[key: string]: Options} = { 'info needs to be collected from.', type: 'string', }, - collectCoverageOnlyFrom: { - description: 'Explicit list of paths coverage will be restricted to.', - string: true, - type: 'array', - }, color: { description: 'Forces test results output color highlighting (even if ' + diff --git a/packages/jest-config/src/Deprecated.ts b/packages/jest-config/src/Deprecated.ts index 647dd29691d3..dacfa12dff55 100644 --- a/packages/jest-config/src/Deprecated.ts +++ b/packages/jest-config/src/Deprecated.ts @@ -14,6 +14,14 @@ const deprecatedOptions: DeprecatedOptions = { '"browser"', )} has been deprecated. Please install "browser-resolve" and use the "resolver" option in Jest configuration as shown in the documentation: https://jestjs.io/docs/configuration#resolver-string`, + collectCoverageOnlyFrom: (_options: { + collectCoverageOnlyFrom?: Record; + }) => ` Option ${chalk.bold( + '"collectCoverageOnlyFrom"', + )} was replaced by ${chalk.bold('"collectCoverageFrom"')}. + + Please update your configuration.`, + extraGlobals: (_options: {extraGlobals?: string}) => ` Option ${chalk.bold( '"extraGlobals"', )} was replaced by ${chalk.bold('"sandboxInjectedGlobals"')}. diff --git a/packages/jest-config/src/ValidConfig.ts b/packages/jest-config/src/ValidConfig.ts index 02b19ee2b820..1526b0cbbeb6 100644 --- a/packages/jest-config/src/ValidConfig.ts +++ b/packages/jest-config/src/ValidConfig.ts @@ -24,9 +24,6 @@ const initialOptions: Config.InitialOptions = { clearMocks: false, collectCoverage: true, collectCoverageFrom: ['src', '!public'], - collectCoverageOnlyFrom: { - '/this-directory-is-covered/Covered.js': true, - }, coverageDirectory: 'coverage', coveragePathIgnorePatterns: [NODE_MODULES_REGEXP], coverageProvider: 'v8', diff --git a/packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap b/packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap index 80f0dc76e6e5..3a7d0dff6d45 100644 --- a/packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap +++ b/packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap @@ -137,6 +137,30 @@ exports[`logs a deprecation warning when 'browser' option is passed 1`] = ` } `; +exports[`logs a deprecation warning when 'collectCoverageOnlyFrom' option is passed 1`] = ` +[MockFunction] { + "calls": Array [ + Array [ + " Deprecation Warning: + + Option "collectCoverageOnlyFrom" was replaced by "collectCoverageFrom". + + Please update your configuration. + + Configuration Documentation: + https://jestjs.io/docs/configuration +", + ], + ], + "results": Array [ + Object { + "type": "return", + "value": undefined, + }, + ], +} +`; + exports[`logs a deprecation warning when 'extraGlobals' option is passed 1`] = ` [MockFunction] { "calls": Array [ diff --git a/packages/jest-config/src/__tests__/normalize.test.ts b/packages/jest-config/src/__tests__/normalize.test.ts index ac1b24a69e8f..8f2956fad502 100644 --- a/packages/jest-config/src/__tests__/normalize.test.ts +++ b/packages/jest-config/src/__tests__/normalize.test.ts @@ -161,65 +161,8 @@ describe('automock', () => { }); }); -describe('collectCoverageOnlyFrom', () => { - it('normalizes all paths relative to rootDir', async () => { - const {options} = await normalize( - { - collectCoverageOnlyFrom: { - 'bar/baz': true, - 'qux/quux/': true, - }, - rootDir: '/root/path/foo/', - }, - {} as Config.Argv, - ); - - const expected = Object.create(null); - expected[expectedPathFooBar] = true; - expected[expectedPathFooQux] = true; - - expect(options.collectCoverageOnlyFrom).toEqual(expected); - }); - - it('does not change absolute paths', async () => { - const {options} = await normalize( - { - collectCoverageOnlyFrom: { - '/an/abs/path': true, - '/another/abs/path': true, - }, - rootDir: '/root/path/foo', - }, - {} as Config.Argv, - ); - - const expected = Object.create(null); - expected[expectedPathAbs] = true; - expected[expectedPathAbsAnother] = true; - - expect(options.collectCoverageOnlyFrom).toEqual(expected); - }); - - it('substitutes tokens', async () => { - const {options} = await normalize( - { - collectCoverageOnlyFrom: { - '/bar/baz': true, - }, - rootDir: '/root/path/foo', - }, - {} as Config.Argv, - ); - - const expected = Object.create(null); - expected[expectedPathFooBar] = true; - - expect(options.collectCoverageOnlyFrom).toEqual(expected); - }); -}); - describe('collectCoverageFrom', () => { - it('substitutes tokens', async () => { + it('ignores tokens', async () => { const barBaz = 'bar/baz'; const quxQuux = 'qux/quux/'; const notQuxQuux = `!${quxQuux}`; @@ -2014,6 +1957,20 @@ describe('logs a deprecation warning', () => { expect(console.warn).toMatchSnapshot(); }); + test("when 'collectCoverageOnlyFrom' option is passed", async () => { + await normalize( + { + collectCoverageOnlyFrom: { + '/this-directory-is-covered/Covered.js': true, + }, + rootDir: '/root/', + }, + {} as Config.Argv, + ); + + expect(console.warn).toMatchSnapshot(); + }); + test("when 'extraGlobals' option is passed", async () => { await normalize( { diff --git a/packages/jest-config/src/__tests__/setFromArgv.test.ts b/packages/jest-config/src/__tests__/setFromArgv.test.ts index 370b0e9cdda4..0b3a72311f5f 100644 --- a/packages/jest-config/src/__tests__/setFromArgv.test.ts +++ b/packages/jest-config/src/__tests__/setFromArgv.test.ts @@ -30,13 +30,13 @@ test('maps special values to valid options', () => { test('maps regular values to themselves', () => { const options = {} as Config.InitialOptions; const argv = { - collectCoverageOnlyFrom: ['a', 'b'], + collectCoverageFrom: '**/*.{js,jsx}', coverageDirectory: 'covDir', watchman: true, } as Config.Argv; expect(setFromArgv(options, argv)).toMatchObject({ - collectCoverageOnlyFrom: ['a', 'b'], + collectCoverageFrom: '**/*.{js,jsx}', coverageDirectory: 'covDir', watchman: true, }); diff --git a/packages/jest-config/src/index.ts b/packages/jest-config/src/index.ts index ba9afa5e100b..de947b1d5de2 100644 --- a/packages/jest-config/src/index.ts +++ b/packages/jest-config/src/index.ts @@ -120,7 +120,6 @@ const groupOptions = ( ci: options.ci, collectCoverage: options.collectCoverage, collectCoverageFrom: options.collectCoverageFrom, - collectCoverageOnlyFrom: options.collectCoverageOnlyFrom, coverageDirectory: options.coverageDirectory, coverageProvider: options.coverageProvider, coverageReporters: options.coverageReporters, diff --git a/packages/jest-config/src/normalize.ts b/packages/jest-config/src/normalize.ts index 753955c89be2..da4bb5977e16 100644 --- a/packages/jest-config/src/normalize.ts +++ b/packages/jest-config/src/normalize.ts @@ -254,27 +254,6 @@ const setupBabelJest = (options: Config.InitialOptionsWithRootDir) => { } }; -const normalizeCollectCoverageOnlyFrom = ( - options: Config.InitialOptionsWithRootDir & - Required>, - key: keyof Pick, -) => { - const initialCollectCoverageFrom = options[key]; - const collectCoverageOnlyFrom: Array = Array.isArray( - initialCollectCoverageFrom, - ) - ? initialCollectCoverageFrom // passed from argv - : Object.keys(initialCollectCoverageFrom); // passed from options - return collectCoverageOnlyFrom.reduce((map, filePath) => { - filePath = path.resolve( - options.rootDir, - replaceRootDirInPath(options.rootDir, filePath), - ); - map[filePath] = true; - return map; - }, Object.create(null)); -}; - const normalizeCollectCoverageFrom = ( options: Config.InitialOptions & Required>, @@ -530,7 +509,6 @@ export default async function normalize( deprecatedConfig: DEPRECATED_CONFIG, exampleConfig: VALID_CONFIG, recursiveDenylist: [ - 'collectCoverageOnlyFrom', // 'coverageThreshold' allows to use 'global' and glob strings on the same // level, there's currently no way we can deal with such config 'coverageThreshold', @@ -627,9 +605,6 @@ export default async function normalize( Required>; let value; switch (key) { - case 'collectCoverageOnlyFrom': - value = normalizeCollectCoverageOnlyFrom(oldOptions, key); - break; case 'setupFiles': case 'setupFilesAfterEnv': case 'snapshotSerializers': diff --git a/packages/jest-core/src/__tests__/watch.test.js b/packages/jest-core/src/__tests__/watch.test.js index 0ef865a7e74a..ef85c3fe1d13 100644 --- a/packages/jest-core/src/__tests__/watch.test.js +++ b/packages/jest-core/src/__tests__/watch.test.js @@ -614,7 +614,6 @@ describe('Watch mode flows', () => { ${'✔︎'} | ${'changedSince'} ${'✔︎'} | ${'collectCoverage'} ${'✔︎'} | ${'collectCoverageFrom'} - ${'✔︎'} | ${'collectCoverageOnlyFrom'} ${'✔︎'} | ${'coverageDirectory'} ${'✔︎'} | ${'coverageReporters'} ${'✖︎'} | ${'coverageThreshold'} diff --git a/packages/jest-core/src/lib/updateGlobalConfig.ts b/packages/jest-core/src/lib/updateGlobalConfig.ts index 4ba644d6bee9..65c136628463 100644 --- a/packages/jest-core/src/lib/updateGlobalConfig.ts +++ b/packages/jest-core/src/lib/updateGlobalConfig.ts @@ -59,10 +59,6 @@ export default function updateGlobalConfig( newConfig.collectCoverageFrom = options.collectCoverageFrom; } - if (options.collectCoverageOnlyFrom !== undefined) { - newConfig.collectCoverageOnlyFrom = options.collectCoverageOnlyFrom; - } - if (options.coverageDirectory !== undefined) { newConfig.coverageDirectory = options.coverageDirectory; } diff --git a/packages/jest-core/src/watch.ts b/packages/jest-core/src/watch.ts index ca0a6a421f26..d1b84c7635bc 100644 --- a/packages/jest-core/src/watch.ts +++ b/packages/jest-core/src/watch.ts @@ -113,7 +113,6 @@ export default async function watch( changedSince, collectCoverage, collectCoverageFrom, - collectCoverageOnlyFrom, coverageDirectory, coverageReporters, findRelatedTests, @@ -134,7 +133,6 @@ export default async function watch( changedSince, collectCoverage, collectCoverageFrom, - collectCoverageOnlyFrom, coverageDirectory, coverageReporters, findRelatedTests, diff --git a/packages/jest-phabricator/README.md b/packages/jest-phabricator/README.md index c657a1f7276c..3f1f19afb900 100644 --- a/packages/jest-phabricator/README.md +++ b/packages/jest-phabricator/README.md @@ -213,7 +213,7 @@ final class JestUnitTestEngine extends ArcanistUnitTestEngine { if (count($paths) < self::TOO_MANY_FILES_TO_COVER) { $options[] = '--findRelatedTests ' . join(' ', $paths); $options[] = '--coverage'; - $options[] = '--collectCoverageOnlyFrom '. join(' ', $paths); + $options[] = '--collectCoverageFrom '. join(' ', $paths); } return $options; diff --git a/packages/jest-repl/src/cli/runtime-cli.ts b/packages/jest-repl/src/cli/runtime-cli.ts index bc5c2a72a8e4..8e156a9364c4 100644 --- a/packages/jest-repl/src/cli/runtime-cli.ts +++ b/packages/jest-repl/src/cli/runtime-cli.ts @@ -102,7 +102,6 @@ export async function run( changedFiles: undefined, collectCoverage: false, collectCoverageFrom: [], - collectCoverageOnlyFrom: undefined, coverageProvider: 'v8', sourcesRelatedToTestsInChangedFiles: undefined, }, diff --git a/packages/jest-reporters/src/generateEmptyCoverage.ts b/packages/jest-reporters/src/generateEmptyCoverage.ts index 72e35e4b73f8..abc3fa017230 100644 --- a/packages/jest-reporters/src/generateEmptyCoverage.ts +++ b/packages/jest-reporters/src/generateEmptyCoverage.ts @@ -36,7 +36,6 @@ export default async function generateEmptyCoverage( changedFiles, collectCoverage: globalConfig.collectCoverage, collectCoverageFrom: globalConfig.collectCoverageFrom, - collectCoverageOnlyFrom: globalConfig.collectCoverageOnlyFrom, coverageProvider: globalConfig.coverageProvider, sourcesRelatedToTestsInChangedFiles, }; diff --git a/packages/jest-runner/src/runTest.ts b/packages/jest-runner/src/runTest.ts index 9bdb6e719216..f743d3b76f6d 100644 --- a/packages/jest-runner/src/runTest.ts +++ b/packages/jest-runner/src/runTest.ts @@ -191,7 +191,6 @@ async function runTestInternal( changedFiles: context.changedFiles, collectCoverage: globalConfig.collectCoverage, collectCoverageFrom: globalConfig.collectCoverageFrom, - collectCoverageOnlyFrom: globalConfig.collectCoverageOnlyFrom, coverageProvider: globalConfig.coverageProvider, sourcesRelatedToTestsInChangedFiles: context.sourcesRelatedToTestsInChangedFiles, diff --git a/packages/jest-runtime/src/__mocks__/createRuntime.js b/packages/jest-runtime/src/__mocks__/createRuntime.js index b22afc6154bf..2830be96376c 100644 --- a/packages/jest-runtime/src/__mocks__/createRuntime.js +++ b/packages/jest-runtime/src/__mocks__/createRuntime.js @@ -105,7 +105,6 @@ module.exports = async function createRuntime(filename, projectConfig) { changedFiles: undefined, collectCoverage: false, collectCoverageFrom: [], - collectCoverageOnlyFrom: undefined, coverageProvider: 'v8', sourcesRelatedToTestsInChangedFiles: undefined, }, diff --git a/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts b/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts index 9921e32b8bbe..5785e98c05a4 100644 --- a/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts +++ b/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts @@ -1823,7 +1823,6 @@ function getCoverageOptions( return { collectCoverage: globalConfig.collectCoverage, collectCoverageFrom: globalConfig.collectCoverageFrom, - collectCoverageOnlyFrom: globalConfig.collectCoverageOnlyFrom, coverageProvider: globalConfig.coverageProvider, supportsDynamicImport: false, supportsExportNamespaceFrom: false, diff --git a/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap b/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap index 152ca5e8cd16..3132902635bc 100644 --- a/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap +++ b/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap @@ -21,7 +21,6 @@ exports[`ScriptTransformer in async mode, passes expected transform options to g }, "collectCoverage": true, "collectCoverageFrom": Array [], - "collectCoverageOnlyFrom": undefined, "config": Object { "automock": false, "cache": true, @@ -154,7 +153,6 @@ exports[`ScriptTransformer passes expected transform options to getCacheKey 1`] }, "collectCoverage": true, "collectCoverageFrom": Array [], - "collectCoverageOnlyFrom": undefined, "config": Object { "automock": false, "cache": true, @@ -261,7 +259,6 @@ exports[`ScriptTransformer passes expected transform options to getCacheKeyAsync }, "collectCoverage": true, "collectCoverageFrom": Array [], - "collectCoverageOnlyFrom": undefined, "config": Object { "automock": false, "cache": true, diff --git a/packages/jest-transform/src/__tests__/shouldInstrument.test.ts b/packages/jest-transform/src/__tests__/shouldInstrument.test.ts index 4bde8a9e2215..a234e11975c5 100644 --- a/packages/jest-transform/src/__tests__/shouldInstrument.test.ts +++ b/packages/jest-transform/src/__tests__/shouldInstrument.test.ts @@ -77,16 +77,6 @@ describe('shouldInstrument', () => { }); }); - it('should return true when file is in collectCoverageOnlyFrom when provided', () => { - testShouldInstrument( - 'collect/only/from/here.js', - { - collectCoverageOnlyFrom: {'collect/only/from/here.js': true}, - }, - defaultConfig, - ); - }); - it('should return true when filename matches collectCoverageFrom', () => { testShouldInstrument( 'do/collect/coverage.js', @@ -167,16 +157,6 @@ describe('shouldInstrument', () => { }); }); - it('when file is not in collectCoverageOnlyFrom when provided', () => { - testShouldInstrument( - 'source_file.js', - { - collectCoverageOnlyFrom: {'collect/only/from/here.js': true}, - }, - defaultConfig, - ); - }); - it('when filename does not match collectCoverageFrom', () => { testShouldInstrument( 'dont/collect/coverage.js', diff --git a/packages/jest-transform/src/shouldInstrument.ts b/packages/jest-transform/src/shouldInstrument.ts index fc1eb95e9e16..d741dd55228a 100644 --- a/packages/jest-transform/src/shouldInstrument.ts +++ b/packages/jest-transform/src/shouldInstrument.ts @@ -60,18 +60,8 @@ export default function shouldInstrument( } } - if ( - // This configuration field contains an object in the form of: - // {'path/to/file.js': true} - options.collectCoverageOnlyFrom && - !options.collectCoverageOnlyFrom[filename] - ) { - return false; - } - if ( // still cover if `only` is specified - !options.collectCoverageOnlyFrom && options.collectCoverageFrom.length && !globsToMatcher(options.collectCoverageFrom)( replacePathSepForGlob(path.relative(config.rootDir, filename)), diff --git a/packages/jest-transform/src/types.ts b/packages/jest-transform/src/types.ts index a86d56e973d1..d2e0d5246913 100644 --- a/packages/jest-transform/src/types.ts +++ b/packages/jest-transform/src/types.ts @@ -11,10 +11,7 @@ import type {Config, TransformTypes} from '@jest/types'; export interface ShouldInstrumentOptions extends Pick< Config.GlobalConfig, - | 'collectCoverage' - | 'collectCoverageFrom' - | 'collectCoverageOnlyFrom' - | 'coverageProvider' + 'collectCoverage' | 'collectCoverageFrom' | 'coverageProvider' > { changedFiles?: Set; sourcesRelatedToTestsInChangedFiles?: Set; diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index fc3de9a49e64..cc23cbbdd21d 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -232,9 +232,6 @@ export type InitialOptions = Partial<{ changedSince: string; collectCoverage: boolean; collectCoverageFrom: Array; - collectCoverageOnlyFrom: { - [key: string]: boolean; - }; coverageDirectory: string; coveragePathIgnorePatterns: Array; coverageProvider: CoverageProvider; @@ -364,9 +361,6 @@ export type GlobalConfig = { ci: boolean; collectCoverage: boolean; collectCoverageFrom: Array; - collectCoverageOnlyFrom?: { - [key: string]: boolean; - }; coverageDirectory: string; coveragePathIgnorePatterns?: Array; coverageProvider: CoverageProvider; @@ -497,7 +491,6 @@ export type Argv = Arguments< clearMocks: boolean; collectCoverage: boolean; collectCoverageFrom: string; - collectCoverageOnlyFrom: Array; color: boolean; colors: boolean; config: string; diff --git a/packages/jest-validate/src/__tests__/fixtures/jestConfig.ts b/packages/jest-validate/src/__tests__/fixtures/jestConfig.ts index dfcc3a5a69c5..6cddb9fbf0f0 100644 --- a/packages/jest-validate/src/__tests__/fixtures/jestConfig.ts +++ b/packages/jest-validate/src/__tests__/fixtures/jestConfig.ts @@ -63,9 +63,6 @@ const validConfig = { clearMocks: false, collectCoverage: true, collectCoverageFrom: ['src', '!public'], - collectCoverageOnlyFrom: { - '/this-directory-is-covered/Covered.js': true, - }, coverageDirectory: 'coverage', coveragePathIgnorePatterns: [NODE_MODULES_REGEXP], coverageReporters: ['json', 'text', 'lcov', 'clover'], diff --git a/packages/jest-watcher/src/types.ts b/packages/jest-watcher/src/types.ts index 63e6f2b81bd0..5a3843f32d7b 100644 --- a/packages/jest-watcher/src/types.ts +++ b/packages/jest-watcher/src/types.ts @@ -53,7 +53,6 @@ export type AllowedConfigOptions = Partial< | 'changedSince' | 'collectCoverage' | 'collectCoverageFrom' - | 'collectCoverageOnlyFrom' | 'coverageDirectory' | 'coverageReporters' | 'findRelatedTests' diff --git a/packages/test-utils/src/config.ts b/packages/test-utils/src/config.ts index 30a8f10865de..92e65d53e91b 100644 --- a/packages/test-utils/src/config.ts +++ b/packages/test-utils/src/config.ts @@ -14,7 +14,6 @@ const DEFAULT_GLOBAL_CONFIG: Config.GlobalConfig = { ci: false, collectCoverage: false, collectCoverageFrom: [], - collectCoverageOnlyFrom: undefined, coverageDirectory: 'coverage', coverageProvider: 'babel', coverageReporters: [], From 4c9a207b340f192c024735abe89a0be90adbc85b Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Sun, 21 Aug 2022 08:58:06 +0300 Subject: [PATCH 2/3] remove broken links --- website/versioned_docs/version-25.x/WatchPlugins.md | 1 - website/versioned_docs/version-26.x/WatchPlugins.md | 1 - website/versioned_docs/version-27.x/WatchPlugins.md | 1 - website/versioned_docs/version-28.0/WatchPlugins.md | 1 - website/versioned_docs/version-28.1/WatchPlugins.md | 1 - 5 files changed, 5 deletions(-) diff --git a/website/versioned_docs/version-25.x/WatchPlugins.md b/website/versioned_docs/version-25.x/WatchPlugins.md index bcf2991083f1..a3064dd394ed 100644 --- a/website/versioned_docs/version-25.x/WatchPlugins.md +++ b/website/versioned_docs/version-25.x/WatchPlugins.md @@ -157,7 +157,6 @@ For stability and safety reasons, only part of the global configuration keys can - [`changedSince`](cli#--changedsince) - [`collectCoverage`](configuration#collectcoverage-boolean) - [`collectCoverageFrom`](configuration#collectcoveragefrom-array) -- [`collectCoverageOnlyFrom`](configuration#collectcoverageonlyfrom-array) - [`coverageDirectory`](configuration#coveragedirectory-string) - [`coverageReporters`](configuration#coveragereporters-arraystring) - [`notify`](configuration#notify-boolean) diff --git a/website/versioned_docs/version-26.x/WatchPlugins.md b/website/versioned_docs/version-26.x/WatchPlugins.md index bcf2991083f1..a3064dd394ed 100644 --- a/website/versioned_docs/version-26.x/WatchPlugins.md +++ b/website/versioned_docs/version-26.x/WatchPlugins.md @@ -157,7 +157,6 @@ For stability and safety reasons, only part of the global configuration keys can - [`changedSince`](cli#--changedsince) - [`collectCoverage`](configuration#collectcoverage-boolean) - [`collectCoverageFrom`](configuration#collectcoveragefrom-array) -- [`collectCoverageOnlyFrom`](configuration#collectcoverageonlyfrom-array) - [`coverageDirectory`](configuration#coveragedirectory-string) - [`coverageReporters`](configuration#coveragereporters-arraystring) - [`notify`](configuration#notify-boolean) diff --git a/website/versioned_docs/version-27.x/WatchPlugins.md b/website/versioned_docs/version-27.x/WatchPlugins.md index bcf2991083f1..a3064dd394ed 100644 --- a/website/versioned_docs/version-27.x/WatchPlugins.md +++ b/website/versioned_docs/version-27.x/WatchPlugins.md @@ -157,7 +157,6 @@ For stability and safety reasons, only part of the global configuration keys can - [`changedSince`](cli#--changedsince) - [`collectCoverage`](configuration#collectcoverage-boolean) - [`collectCoverageFrom`](configuration#collectcoveragefrom-array) -- [`collectCoverageOnlyFrom`](configuration#collectcoverageonlyfrom-array) - [`coverageDirectory`](configuration#coveragedirectory-string) - [`coverageReporters`](configuration#coveragereporters-arraystring) - [`notify`](configuration#notify-boolean) diff --git a/website/versioned_docs/version-28.0/WatchPlugins.md b/website/versioned_docs/version-28.0/WatchPlugins.md index bcf2991083f1..a3064dd394ed 100644 --- a/website/versioned_docs/version-28.0/WatchPlugins.md +++ b/website/versioned_docs/version-28.0/WatchPlugins.md @@ -157,7 +157,6 @@ For stability and safety reasons, only part of the global configuration keys can - [`changedSince`](cli#--changedsince) - [`collectCoverage`](configuration#collectcoverage-boolean) - [`collectCoverageFrom`](configuration#collectcoveragefrom-array) -- [`collectCoverageOnlyFrom`](configuration#collectcoverageonlyfrom-array) - [`coverageDirectory`](configuration#coveragedirectory-string) - [`coverageReporters`](configuration#coveragereporters-arraystring) - [`notify`](configuration#notify-boolean) diff --git a/website/versioned_docs/version-28.1/WatchPlugins.md b/website/versioned_docs/version-28.1/WatchPlugins.md index bcf2991083f1..a3064dd394ed 100644 --- a/website/versioned_docs/version-28.1/WatchPlugins.md +++ b/website/versioned_docs/version-28.1/WatchPlugins.md @@ -157,7 +157,6 @@ For stability and safety reasons, only part of the global configuration keys can - [`changedSince`](cli#--changedsince) - [`collectCoverage`](configuration#collectcoverage-boolean) - [`collectCoverageFrom`](configuration#collectcoveragefrom-array) -- [`collectCoverageOnlyFrom`](configuration#collectcoverageonlyfrom-array) - [`coverageDirectory`](configuration#coveragedirectory-string) - [`coverageReporters`](configuration#coveragereporters-arraystring) - [`notify`](configuration#notify-boolean) From 97b5c937de3691d563739fdd63f4e9084cd7a919 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Sun, 21 Aug 2022 08:59:07 +0300 Subject: [PATCH 3/3] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 830993a75ed1..c8b80f7bccd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - `[expect]` [**BREAKING**] Differentiate between `MatcherContext` `MatcherUtils` and `MatcherState` types ([#13141](https://github.com/facebook/jest/pull/13141)) - `[jest-circus]` Add support for `test.failing.each` ([#13142](https://github.com/facebook/jest/pull/13142)) - `[jest-config]` [**BREAKING**] Make `snapshotFormat` default to `escapeString: false` and `printBasicPrototype: false` ([#13036](https://github.com/facebook/jest/pull/13036)) +- `[jest-config]` [**BREAKING**] Remove undocumented `collectCoverageOnlyFrom` option ([#13156](https://github.com/facebook/jest/pull/13156)) - `[jest-environment-jsdom]` [**BREAKING**] Upgrade to `jsdom@20` ([#13037](https://github.com/facebook/jest/pull/13037), [#13058](https://github.com/facebook/jest/pull/13058)) - `[@jest/globals]` Add `jest.Mocked`, `jest.MockedClass`, `jest.MockedFunction` and `jest.MockedObject` utility types ([#12727](https://github.com/facebook/jest/pull/12727)) - `[jest-mock]` [**BREAKING**] Refactor `Mocked*` utility types. `MaybeMockedDeep` and `MaybeMocked` became `Mocked` and `MockedShallow` respectively; only deep mocked variants of `MockedClass`, `MockedFunction` and `MockedObject` are exported ([#13123](https://github.com/facebook/jest/pull/13123), [#13124](https://github.com/facebook/jest/pull/13124))