Skip to content

Commit

Permalink
Add .pnp.js to transformIgnorePatterns defaults (#10383)
Browse files Browse the repository at this point in the history
  • Loading branch information
irudoy committed Aug 10, 2020
1 parent 1d5074a commit 96097ad
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
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))
- `[docs]` Update snapshot testing documentation([#10359](https://github.com/facebook/jest/pull/10359))
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

0 comments on commit 96097ad

Please sign in to comment.