From c0c2351be290ca839b3e1f86d00838cfad550698 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Wed, 20 Apr 2022 17:08:25 +0300 Subject: [PATCH 1/3] refactor(jest-config): do not normalize deprecated --- docs/Configuration.md | 6 - packages/jest-config/src/Deprecated.ts | 28 +- .../__snapshots__/normalize.test.ts.snap | 259 ++++++++++++------ .../src/__tests__/normalize.test.ts | 176 +++++------- packages/jest-config/src/normalize.ts | 71 +---- packages/jest-types/src/Config.ts | 16 -- .../version-27.4/Configuration.md | 2 - .../version-27.5/Configuration.md | 2 - 8 files changed, 245 insertions(+), 315 deletions(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index 11d60d5f4896..212e391955c1 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -1108,12 +1108,6 @@ If you want a path to be [relative to the root directory of your project](#rootd For example, Jest ships with several plug-ins to `jasmine` that work by monkey-patching the jasmine API. If you wanted to add even more jasmine plugins to the mix (or if you wanted some custom, project-wide matchers for example), you could do so in these modules. -:::info - -`setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`. - -::: - Example `setupFilesAfterEnv` array in a jest.config.js: ```js diff --git a/packages/jest-config/src/Deprecated.ts b/packages/jest-config/src/Deprecated.ts index 905d3ebdde5b..647dd29691d3 100644 --- a/packages/jest-config/src/Deprecated.ts +++ b/packages/jest-config/src/Deprecated.ts @@ -7,9 +7,6 @@ import chalk = require('chalk'); import type {DeprecatedOptions} from 'jest-validate'; -import {format as prettyFormat} from 'pretty-format'; - -const format = (value: unknown) => prettyFormat(value, {min: true}); const deprecatedOptions: DeprecatedOptions = { browser: () => @@ -29,7 +26,7 @@ const deprecatedOptions: DeprecatedOptions = { Please update your configuration.`, - preprocessorIgnorePatterns: (options: { + preprocessorIgnorePatterns: (_options: { preprocessorIgnorePatterns?: Array; }) => ` Option ${chalk.bold( '"preprocessorIgnorePatterns"', @@ -37,16 +34,9 @@ const deprecatedOptions: DeprecatedOptions = { '"transformIgnorePatterns"', )}, which support multiple preprocessors. - Jest now treats your current configuration as: - { - ${chalk.bold('"transformIgnorePatterns"')}: ${chalk.bold( - format(options.preprocessorIgnorePatterns), - )} - } - Please update your configuration.`, - scriptPreprocessor: (options: { + scriptPreprocessor: (_options: { scriptPreprocessor?: string; }) => ` Option ${chalk.bold( '"scriptPreprocessor"', @@ -54,13 +44,6 @@ const deprecatedOptions: DeprecatedOptions = { '"transform"', )}, which support multiple preprocessors. - Jest now treats your current configuration as: - { - ${chalk.bold('"transform"')}: ${chalk.bold( - `{".*": ${format(options.scriptPreprocessor)}}`, - )} - } - Please update your configuration.`, setupTestFrameworkScriptFile: (_options: { @@ -73,17 +56,12 @@ const deprecatedOptions: DeprecatedOptions = { Please update your configuration.`, - testPathDirs: (options: { + testPathDirs: (_options: { testPathDirs?: Array; }) => ` Option ${chalk.bold('"testPathDirs"')} was replaced by ${chalk.bold( '"roots"', )}. - Jest now treats your current configuration as: - { - ${chalk.bold('"roots"')}: ${chalk.bold(format(options.testPathDirs))} - } - Please update your configuration. `, 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 284570033fc2..00386d08b28c 100644 --- a/packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap +++ b/packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap @@ -1,22 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Upgrade help logs a warning when \`scriptPreprocessor\` and/or \`preprocessorIgnorePatterns\` are used 1`] = ` -" Deprecation Warning: - - Option "preprocessorIgnorePatterns" was replaced by "transformIgnorePatterns", which support multiple preprocessors. - - Jest now treats your current configuration as: - { - "transformIgnorePatterns": ["bar/baz", "qux/quux"] - } - - Please update your configuration. - - Configuration Documentation: - https://jestjs.io/docs/configuration -" -`; - exports[`displayName generates a default color for the runner jest-runner 1`] = `"yellow"`; exports[`displayName generates a default color for the runner jest-runner-eslint 1`] = `"magenta"`; @@ -132,7 +115,29 @@ exports[`extensionsToTreatAsEsm throws on .mjs 1`] = ` " `; -exports[`extraGlobals logs a deprecation warning when \`extraGlobals\` is used 1`] = ` +exports[`logs a deprecation warning when 'browser' option is passed 1`] = ` +[MockFunction] { + "calls": Array [ + Array [ + " Deprecation Warning: + + Option "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 + + 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 [ Array [ @@ -156,7 +161,7 @@ exports[`extraGlobals logs a deprecation warning when \`extraGlobals\` is used 1 } `; -exports[`moduleLoader logs a deprecation warning when \`moduleLoader\` is used 1`] = ` +exports[`logs a deprecation warning when 'moduleLoader' option is passed 1`] = ` [MockFunction] { "calls": Array [ Array [ @@ -180,6 +185,151 @@ exports[`moduleLoader logs a deprecation warning when \`moduleLoader\` is used 1 } `; +exports[`logs a deprecation warning when 'preprocessorIgnorePatterns' option is passed 1`] = ` +[MockFunction] { + "calls": Array [ + Array [ + " Deprecation Warning: + + Option "preprocessorIgnorePatterns" was replaced by "transformIgnorePatterns", which support multiple preprocessors. + + Please update your configuration. + + Configuration Documentation: + https://jestjs.io/docs/configuration +", + ], + ], + "results": Array [ + Object { + "type": "return", + "value": undefined, + }, + ], +} +`; + +exports[`logs a deprecation warning when 'scriptPreprocessor' option is passed 1`] = ` +[MockFunction] { + "calls": Array [ + Array [ + " Deprecation Warning: + + Option "scriptPreprocessor" was replaced by "transform", which support multiple preprocessors. + + Please update your configuration. + + Configuration Documentation: + https://jestjs.io/docs/configuration +", + ], + ], + "results": Array [ + Object { + "type": "return", + "value": undefined, + }, + ], +} +`; + +exports[`logs a deprecation warning when 'setupTestFrameworkScriptFile' option is passed 1`] = ` +[MockFunction] { + "calls": Array [ + Array [ + " Deprecation Warning: + + Option "setupTestFrameworkScriptFile" was replaced by configuration "setupFilesAfterEnv", which supports multiple paths. + + Please update your configuration. + + Configuration Documentation: + https://jestjs.io/docs/configuration +", + ], + ], + "results": Array [ + Object { + "type": "return", + "value": undefined, + }, + ], +} +`; + +exports[`logs a deprecation warning when 'testPathDirs' option is passed 1`] = ` +[MockFunction] { + "calls": Array [ + Array [ + " Deprecation Warning: + + Option "testPathDirs" was replaced by "roots". + + Please update your configuration. + + + Configuration Documentation: + https://jestjs.io/docs/configuration +", + ], + ], + "results": Array [ + Object { + "type": "return", + "value": undefined, + }, + ], +} +`; + +exports[`logs a deprecation warning when 'testURL' option is passed 1`] = ` +[MockFunction] { + "calls": Array [ + Array [ + " Deprecation Warning: + + Option "testURL" was replaced by passing the URL via "testEnvironmentOptions.url". + + Please update your configuration. + + Configuration Documentation: + https://jestjs.io/docs/configuration +", + ], + ], + "results": Array [ + Object { + "type": "return", + "value": undefined, + }, + ], +} +`; + +exports[`logs a deprecation warning when 'timers' option is passed 1`] = ` +[MockFunction] { + "calls": Array [ + Array [ + " Deprecation Warning: + + Option "timers" was replaced by "fakeTimers". + + Please update your configuration. + + Configuration Documentation: + https://jestjs.io/docs/configuration +", + ], + ], + "results": Array [ + Object { + "type": "return", + "value": undefined, + }, + ], +} +`; + exports[`preset throws when module was found but no "jest-preset.js" or "jest-preset.json" files 1`] = ` "Validation Error: @@ -288,29 +438,6 @@ exports[`runner throw error when a runner is not found 1`] = ` " `; -exports[`setupTestFrameworkScriptFile logs a deprecation warning when \`setupTestFrameworkScriptFile\` is used 1`] = ` -" Deprecation Warning: - - Option "setupTestFrameworkScriptFile" was replaced by configuration "setupFilesAfterEnv", which supports multiple paths. - - Please update your configuration. - - Configuration Documentation: - https://jestjs.io/docs/configuration -" -`; - -exports[`setupTestFrameworkScriptFile logs an error when \`setupTestFrameworkScriptFile\` and \`setupFilesAfterEnv\` are used 1`] = ` -"Validation Error: - - Options: setupTestFrameworkScriptFile and setupFilesAfterEnv cannot be used together. - Please change your configuration to only use setupFilesAfterEnv. - - Configuration Documentation: - https://jestjs.io/docs/configuration -" -`; - exports[`testEnvironment throws on invalid environment names 1`] = ` "Validation Error: @@ -345,54 +472,6 @@ exports[`testTimeout should throw an error if timeout is a negative number 1`] = " `; -exports[`testURL logs a deprecation warning when \`testURL\` is used 1`] = ` -[MockFunction] { - "calls": Array [ - Array [ - " Deprecation Warning: - - Option "testURL" was replaced by passing the URL via "testEnvironmentOptions.url". - - Please update your configuration. - - Configuration Documentation: - https://jestjs.io/docs/configuration -", - ], - ], - "results": Array [ - Object { - "type": "return", - "value": undefined, - }, - ], -} -`; - -exports[`timers logs a deprecation warning when \`timers\` is used 1`] = ` -[MockFunction] { - "calls": Array [ - Array [ - " Deprecation Warning: - - Option "timers" was replaced by "fakeTimers". - - Please update your configuration. - - Configuration Documentation: - https://jestjs.io/docs/configuration -", - ], - ], - "results": Array [ - Object { - "type": "return", - "value": undefined, - }, - ], -} -`; - exports[`watchPlugins throw error when a watch plugin is not found 1`] = ` "Validation Error: diff --git a/packages/jest-config/src/__tests__/normalize.test.ts b/packages/jest-config/src/__tests__/normalize.test.ts index 457baef302f1..2f479ef77670 100644 --- a/packages/jest-config/src/__tests__/normalize.test.ts +++ b/packages/jest-config/src/__tests__/normalize.test.ts @@ -521,45 +521,6 @@ describe('setupFilesAfterEnv', () => { }); }); -describe('setupTestFrameworkScriptFile', () => { - let Resolver; - - beforeEach(() => { - (console.warn as unknown as jest.SpyInstance).mockImplementation(() => {}); - Resolver = require('jest-resolve').default; - Resolver.findNodeModule = jest.fn(name => - name.startsWith('/') ? name : `/root/path/foo${path.sep}${name}`, - ); - }); - - it('logs a deprecation warning when `setupTestFrameworkScriptFile` is used', async () => { - await normalize( - { - rootDir: '/root/path/foo', - setupTestFrameworkScriptFile: 'bar/baz', - }, - {} as Config.Argv, - ); - - expect( - (console.warn as unknown as jest.SpyInstance).mock.calls[0][0], - ).toMatchSnapshot(); - }); - - it('logs an error when `setupTestFrameworkScriptFile` and `setupFilesAfterEnv` are used', async () => { - await expect( - normalize( - { - rootDir: '/root/path/foo', - setupFilesAfterEnv: ['bar/baz'], - setupTestFrameworkScriptFile: 'bar/baz', - }, - {} as Config.Argv, - ), - ).rejects.toThrowErrorMatchingSnapshot(); - }); -}); - describe('coveragePathIgnorePatterns', () => { it('does not normalize paths relative to rootDir', async () => { // This is a list of patterns, so we can't assume any of them are @@ -927,45 +888,6 @@ describe('babel-jest', () => { }); }); -describe('Upgrade help', () => { - beforeEach(() => { - (console.warn as unknown as jest.SpyInstance).mockImplementation(() => {}); - - const Resolver = require('jest-resolve').default; - Resolver.findNodeModule = jest.fn(name => { - if (name == 'bar/baz') { - return '/node_modules/bar/baz'; - } - return findNodeModule(name); - }); - }); - - it('logs a warning when `scriptPreprocessor` and/or `preprocessorIgnorePatterns` are used', async () => { - const {options: options, hasDeprecationWarnings} = await normalize( - { - preprocessorIgnorePatterns: ['bar/baz', 'qux/quux'], - rootDir: '/root/path/foo', - scriptPreprocessor: 'bar/baz', - }, - {} as Config.Argv, - ); - - expect(options.transform).toEqual([['.*', '/node_modules/bar/baz', {}]]); - expect(options.transformIgnorePatterns).toEqual([ - joinForPattern('bar', 'baz'), - joinForPattern('qux', 'quux'), - ]); - - expect(options).not.toHaveProperty('scriptPreprocessor'); - expect(options).not.toHaveProperty('preprocessorIgnorePatterns'); - expect(hasDeprecationWarnings).toBeTruthy(); - - expect( - (console.warn as unknown as jest.SpyInstance).mock.calls[0][0], - ).toMatchSnapshot(); - }); -}); - describe('testRegex', () => { it('testRegex empty string is mapped to empty array', async () => { const {options} = await normalize( @@ -2017,84 +1939,122 @@ describe('updateSnapshot', () => { }); }); -describe('testURL', () => { - beforeEach(() => { - jest.mocked(console.warn).mockImplementation(() => {}); +describe('shards', () => { + it('should be object if defined', async () => { + const {options} = await normalize({rootDir: '/root/'}, { + shard: '1/2', + } as Config.Argv); + + expect(options.shard).toEqual({shardCount: 2, shardIndex: 1}); }); +}); - it('logs a deprecation warning when `testURL` is used', async () => { +describe('logs a deprecation warning', () => { + test("when 'browser' option is passed", async () => { await normalize( { + browser: true, rootDir: '/root/', - testURL: 'https://jestjs.io/', }, {} as Config.Argv, ); expect(console.warn).toMatchSnapshot(); }); -}); -describe('timers', () => { - beforeEach(() => { - jest.mocked(console.warn).mockImplementation(() => {}); + test("when 'extraGlobals' option is passed", async () => { + await normalize( + { + extraGlobals: ['Math'], + rootDir: '/root/', + }, + {} as Config.Argv, + ); + + expect(console.warn).toMatchSnapshot(); }); - it('logs a deprecation warning when `timers` is used', async () => { + test("when 'moduleLoader' option is passed", async () => { await normalize( { + moduleLoader: '/runtime.js', rootDir: '/root/', - timers: 'real', }, {} as Config.Argv, ); expect(console.warn).toMatchSnapshot(); }); -}); -describe('extraGlobals', () => { - beforeEach(() => { - jest.mocked(console.warn).mockImplementation(() => {}); + test("when 'preprocessorIgnorePatterns' option is passed", async () => { + await normalize( + { + preprocessorIgnorePatterns: ['/node_modules/'], + rootDir: '/root/', + }, + {} as Config.Argv, + ); + + expect(console.warn).toMatchSnapshot(); }); - it('logs a deprecation warning when `extraGlobals` is used', async () => { + test("when 'scriptPreprocessor' option is passed", async () => { await normalize( { - extraGlobals: ['Math'], rootDir: '/root/', + scriptPreprocessor: 'preprocessor.js', }, {} as Config.Argv, ); expect(console.warn).toMatchSnapshot(); }); -}); -describe('moduleLoader', () => { - beforeEach(() => { - jest.mocked(console.warn).mockImplementation(() => {}); + test("when 'setupTestFrameworkScriptFile' option is passed", async () => { + await normalize( + { + rootDir: '/root/', + setupTestFrameworkScriptFile: 'setup.js', + }, + {} as Config.Argv, + ); + + expect(console.warn).toMatchSnapshot(); }); - it('logs a deprecation warning when `moduleLoader` is used', async () => { + test("when 'testPathDirs' option is passed", async () => { await normalize( { - moduleLoader: '/runtime.js', rootDir: '/root/', + testPathDirs: [''], }, {} as Config.Argv, ); expect(console.warn).toMatchSnapshot(); }); -}); -describe('shards', () => { - it('should be object if defined', async () => { - const {options} = await normalize({rootDir: '/root/'}, { - shard: '1/2', - } as Config.Argv); + test("when 'testURL' option is passed", async () => { + await normalize( + { + rootDir: '/root/', + testURL: 'https://jestjs.io', + }, + {} as Config.Argv, + ); - expect(options.shard).toEqual({shardCount: 2, shardIndex: 1}); + expect(console.warn).toMatchSnapshot(); + }); + + test("when 'timers' option is passed", async () => { + await normalize( + { + rootDir: '/root/', + timers: 'real', + }, + {} as Config.Argv, + ); + + expect(console.warn).toMatchSnapshot(); }); }); diff --git a/packages/jest-config/src/normalize.ts b/packages/jest-config/src/normalize.ts index 1f1fa8c65d13..d2fc5ade328e 100644 --- a/packages/jest-config/src/normalize.ts +++ b/packages/jest-config/src/normalize.ts @@ -327,44 +327,6 @@ const normalizeUnmockedModulePathPatterns = ( replacePathSepForRegex(pattern.replace(//g, options.rootDir)), ); -const normalizePreprocessor = ( - options: Config.InitialOptionsWithRootDir, -): Config.InitialOptionsWithRootDir => { - if (options.scriptPreprocessor && options.transform) { - throw createConfigError( - ` Options: ${chalk.bold('scriptPreprocessor')} and ${chalk.bold( - 'transform', - )} cannot be used together. - Please change your configuration to only use ${chalk.bold('transform')}.`, - ); - } - - if (options.preprocessorIgnorePatterns && options.transformIgnorePatterns) { - throw createConfigError( - ` Options ${chalk.bold('preprocessorIgnorePatterns')} and ${chalk.bold( - 'transformIgnorePatterns', - )} cannot be used together. - Please change your configuration to only use ${chalk.bold( - 'transformIgnorePatterns', - )}.`, - ); - } - - if (options.scriptPreprocessor) { - options.transform = { - '.*': options.scriptPreprocessor, - }; - } - - if (options.preprocessorIgnorePatterns) { - options.transformIgnorePatterns = options.preprocessorIgnorePatterns; - } - - delete options.scriptPreprocessor; - delete options.preprocessorIgnorePatterns; - return options; -}; - const normalizeMissingOptions = ( options: Config.InitialOptionsWithRootDir, configPath: string | null | undefined, @@ -573,13 +535,11 @@ export default async function normalize( ], }); - let options = normalizePreprocessor( - normalizeReporters( - normalizeMissingOptions( - normalizeRootDir(setFromArgv(initialOptions, argv)), - configPath, - projectIndex, - ), + let options = normalizeReporters( + normalizeMissingOptions( + normalizeRootDir(setFromArgv(initialOptions, argv)), + configPath, + projectIndex, ), ); @@ -591,22 +551,6 @@ export default async function normalize( options.setupFilesAfterEnv = []; } - if ( - options.setupTestFrameworkScriptFile && - options.setupFilesAfterEnv.length > 0 - ) { - throw createConfigError(` Options: ${chalk.bold( - 'setupTestFrameworkScriptFile', - )} and ${chalk.bold('setupFilesAfterEnv')} cannot be used together. - Please change your configuration to only use ${chalk.bold( - 'setupFilesAfterEnv', - )}.`); - } - - if (options.setupTestFrameworkScriptFile) { - options.setupFilesAfterEnv.push(options.setupTestFrameworkScriptFile); - } - options.testEnvironment = resolveTestEnvironment({ requireResolveFunction: require.resolve, rootDir: options.rootDir, @@ -615,11 +559,6 @@ export default async function normalize( require.resolve(DEFAULT_CONFIG.testEnvironment), }); - if (!options.roots && options.testPathDirs) { - options.roots = options.testPathDirs; - delete options.testPathDirs; - } - if (!options.roots) { options.roots = [options.rootDir]; } diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index 7cc11a5df789..1d3f19457b95 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -277,10 +277,6 @@ export type InitialOptions = Partial<{ onlyFailures: boolean; outputFile: string; passWithNoTests: boolean; - /** - * @deprecated Use `transformIgnorePatterns` options instead. - */ - preprocessorIgnorePatterns: Array; preset: string | null | undefined; prettierPath: string | null | undefined; projects: Array; @@ -295,15 +291,7 @@ export type InitialOptions = Partial<{ runTestsByPath: boolean; runtime: string; sandboxInjectedGlobals: Array; - /** - * @deprecated Use `transform` options instead. - */ - scriptPreprocessor: string; setupFiles: Array; - /** - * @deprecated Use `setupFilesAfterEnv` options instead. - */ - setupTestFrameworkScriptFile: string; setupFilesAfterEnv: Array; silent: boolean; skipFilter: boolean; @@ -319,10 +307,6 @@ export type InitialOptions = Partial<{ testLocationInResults: boolean; testMatch: Array; testNamePattern: string; - /** - * @deprecated Use `roots` options instead. - */ - testPathDirs: Array; testPathIgnorePatterns: Array; testRegex: string | Array; testResultsProcessor: string; diff --git a/website/versioned_docs/version-27.4/Configuration.md b/website/versioned_docs/version-27.4/Configuration.md index de7e3dd8d032..4f86bbd3f342 100644 --- a/website/versioned_docs/version-27.4/Configuration.md +++ b/website/versioned_docs/version-27.4/Configuration.md @@ -918,8 +918,6 @@ If you want a path to be [relative to the root directory of your project](#rootd For example, Jest ships with several plug-ins to `jasmine` that work by monkey-patching the jasmine API. If you wanted to add even more jasmine plugins to the mix (or if you wanted some custom, project-wide matchers for example), you could do so in these modules. -_Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ - Example `setupFilesAfterEnv` array in a jest.config.js: ```js diff --git a/website/versioned_docs/version-27.5/Configuration.md b/website/versioned_docs/version-27.5/Configuration.md index de7e3dd8d032..4f86bbd3f342 100644 --- a/website/versioned_docs/version-27.5/Configuration.md +++ b/website/versioned_docs/version-27.5/Configuration.md @@ -918,8 +918,6 @@ If you want a path to be [relative to the root directory of your project](#rootd For example, Jest ships with several plug-ins to `jasmine` that work by monkey-patching the jasmine API. If you wanted to add even more jasmine plugins to the mix (or if you wanted some custom, project-wide matchers for example), you could do so in these modules. -_Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ - Example `setupFilesAfterEnv` array in a jest.config.js: ```js From 04a3cb3b2c4d67e9acd20e0fc9c48283caefab0a Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Wed, 20 Apr 2022 18:30:05 +0300 Subject: [PATCH 2/3] add changelog entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d69b328c1e4..4cdee711f967 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - `[jest-config]` [**BREAKING**] Rename `moduleLoader` to `runtime` ([#10817](https://github.com/facebook/jest/pull/10817)) - `[jest-config]` [**BREAKING**] Rename `extraGlobals` to `sandboxInjectedGlobals` ([#10817](https://github.com/facebook/jest/pull/10817)) - `[jest-config]` [**BREAKING**] Throw an error instead of showing a warning if multiple configs are used ([#12510](https://github.com/facebook/jest/pull/12510)) +- `[jest-config]` [**BREAKING**] Do not normalize long deprecated configuration options `preprocessorIgnorePatterns`,`scriptPreprocessor`, `setupTestFrameworkScriptFile` and `testPathDirs` ([#1251270110](https://github.com/facebook/jest/pull/12701)) - `[jest-cli, jest-core]` Add `--ignoreProjects` CLI argument to ignore test suites by project name ([#12620](https://github.com/facebook/jest/pull/12620)) - `[jest-core]` Pass project config to `globalSetup`/`globalTeardown` function as second argument ([#12440](https://github.com/facebook/jest/pull/12440)) - `[jest-core]` Stabilize test runners with event emitters ([#12641](https://github.com/facebook/jest/pull/12641)) @@ -38,7 +39,7 @@ - `[jest-mock]` [**BREAKING**] Improve the usage of `jest.fn` generic type argument ([#12489](https://github.com/facebook/jest/pull/12489)) - `[jest-mock]` Add support for auto-mocking async generator functions ([#11080](https://github.com/facebook/jest/pull/11080)) - `[jest-mock]` Add `contexts` member to mock functions ([#12601](https://github.com/facebook/jest/pull/12601)) -- `[@jest/reporters]` Add GitHub Actions reporter ([#11320](https://github.com/facebook/jest/pull/11320), [#12658](https://github.com/facebook/jest/pull/12658) +- `[@jest/reporters]` Add GitHub Actions reporter ([#11320](https://github.com/facebook/jest/pull/11320), [#12658](https://github.com/facebook/jest/pull/12658)) - `[@jest/reporters]` Pass `reporterContext` to custom reporter constructors as third argument ([#12657](https://github.com/facebook/jest/pull/12657)) - `[jest-resolve]` [**BREAKING**] Add support for `package.json` `exports` ([#11961](https://github.com/facebook/jest/pull/11961), [#12373](https://github.com/facebook/jest/pull/12373)) - `[jest-resolve]` Support package self-reference ([#12682](https://github.com/facebook/jest/pull/12682)) From edff5d95dec7b07ae0bddf96490e72c1ac015cce Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Wed, 20 Apr 2022 19:25:21 +0300 Subject: [PATCH 3/3] fix: mockImplementation --- packages/jest-config/src/__tests__/normalize.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/jest-config/src/__tests__/normalize.test.ts b/packages/jest-config/src/__tests__/normalize.test.ts index 2f479ef77670..1fc435b0ecfb 100644 --- a/packages/jest-config/src/__tests__/normalize.test.ts +++ b/packages/jest-config/src/__tests__/normalize.test.ts @@ -1950,6 +1950,10 @@ describe('shards', () => { }); describe('logs a deprecation warning', () => { + beforeEach(() => { + (console.warn as unknown as jest.SpyInstance).mockImplementation(() => {}); + }); + test("when 'browser' option is passed", async () => { await normalize( {