diff --git a/CHANGELOG.md b/CHANGELOG.md index c622bdf254bf..82fa1f1190a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Fixes +- `[jest-config]` Add `.pnp.js` to `transformIgnorePatterns` defaults ([#10383](https://github.com/facebook/jest/pull/10383)) - `[jest-leak-detector]` Wait properly for GC runs due to changes in Node 14.7 ([#10366](https://github.com/facebook/jest/pull/10366)) - `[jest-worker]` Downgrade minimum node version to 10.13 ([#10352](https://github.com/facebook/jest/pull/10352)) - `[docs]` Update snapshot testing documentation([#10359](https://github.com/facebook/jest/pull/10359)) diff --git a/docs/Configuration.md b/docs/Configuration.md index 65d80f43744b..406f48fa493f 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -1165,7 +1165,7 @@ _Note: when adding additional code transformers, this will overwrite the default ### `transformIgnorePatterns` [array\] -Default: `["/node_modules/"]` +Default: `["/node_modules/", "\\.pnp\\.[^\\\/]+$"]` An array of regexp pattern strings that are matched against all source file paths before transformation. If the test path matches any of the patterns, it will not be transformed. diff --git a/e2e/__tests__/__snapshots__/showConfig.test.ts.snap b/e2e/__tests__/__snapshots__/showConfig.test.ts.snap index 3f4e045e6cc6..77708ecfc22e 100644 --- a/e2e/__tests__/__snapshots__/showConfig.test.ts.snap +++ b/e2e/__tests__/__snapshots__/showConfig.test.ts.snap @@ -72,7 +72,8 @@ exports[`--showConfig outputs config info and exits 1`] = ` ] ], "transformIgnorePatterns": [ - "/node_modules/" + "/node_modules/", + "<>" ], "watchPathIgnorePatterns": [] } diff --git a/e2e/__tests__/showConfig.test.ts b/e2e/__tests__/showConfig.test.ts index 44338280551d..0ef9c2a51ef5 100644 --- a/e2e/__tests__/showConfig.test.ts +++ b/e2e/__tests__/showConfig.test.ts @@ -31,6 +31,7 @@ test('--showConfig outputs config info and exits', () => { stdout = stdout .replace(/\\\\node_modules\\\\/g, 'node_modules') + .replace(/\\\\\.pnp\\\\\.\[\^[/\\]+\]\+\$/g, '<>') .replace(/\\\\(?:([^.]+?)|$)/g, '/$1') .replace(/"cacheDirectory": "(.+)"/g, '"cacheDirectory": "/tmp/jest"') .replace(/"name": "(.+)"/g, '"name": "[md5 hash]"') diff --git a/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap b/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap index f00ac27eea2f..70e36b545cad 100644 --- a/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap +++ b/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap @@ -222,7 +222,8 @@ module.exports = { // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation // transformIgnorePatterns: [ - // \\"/node_modules/\\" + // \\"/node_modules/\\", + // \\"\\\\\\\\.pnp\\\\\\\\.[^\\\\\\\\/]+$\\" // ], // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them diff --git a/packages/jest-config/src/Defaults.ts b/packages/jest-config/src/Defaults.ts index e86c3174785c..8f496952ea0e 100644 --- a/packages/jest-config/src/Defaults.ts +++ b/packages/jest-config/src/Defaults.ts @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +import {sep} from 'path'; import type {Config} from '@jest/types'; import {replacePathSepForRegex} from 'jest-regex-util'; import {NODE_MODULES} from './constants'; @@ -63,7 +64,7 @@ const defaultOptions: Config.DefaultOptions = { testSequencer: '@jest/test-sequencer', testURL: 'http://localhost', timers: 'real', - transformIgnorePatterns: [NODE_MODULES_REGEXP], + transformIgnorePatterns: [NODE_MODULES_REGEXP, `\\.pnp\\.[^\\${sep}]+$`], useStderr: false, watch: false, watchPathIgnorePatterns: [],