Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .pnp.js to transformIgnorePatterns defaults #10383

Merged
merged 2 commits into from Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion docs/Configuration.md
Expand Up @@ -1165,7 +1165,7 @@ _Note: when adding additional code transformers, this will overwrite the default

### `transformIgnorePatterns` [array\<string>]

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.

Expand Down
3 changes: 2 additions & 1 deletion e2e/__tests__/__snapshots__/showConfig.test.ts.snap
Expand Up @@ -72,7 +72,8 @@ exports[`--showConfig outputs config info and exits 1`] = `
]
],
"transformIgnorePatterns": [
"/node_modules/"
"/node_modules/",
"<<REPLACED_PNP_PATH>>"
],
"watchPathIgnorePatterns": []
}
Expand Down
1 change: 1 addition & 0 deletions e2e/__tests__/showConfig.test.ts
Expand Up @@ -31,6 +31,7 @@ test('--showConfig outputs config info and exits', () => {

stdout = stdout
.replace(/\\\\node_modules\\\\/g, 'node_modules')
.replace(/\\\\\.pnp\\\\\.\[\^[/\\]+\]\+\$/g, '<<REPLACED_PNP_PATH>>')
.replace(/\\\\(?:([^.]+?)|$)/g, '/$1')
.replace(/"cacheDirectory": "(.+)"/g, '"cacheDirectory": "/tmp/jest"')
.replace(/"name": "(.+)"/g, '"name": "[md5 hash]"')
Expand Down
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-config/src/Defaults.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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: [],
Expand Down