Skip to content

Commit 7d7e97f

Browse files
authored
fix: simplify transform RegExp (#10207)
1 parent ecb31a7 commit 7d7e97f

File tree

32 files changed

+64
-68
lines changed

32 files changed

+64
-68
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
### Fixes
88

9+
- `[jest-config]` Simplify transform RegExp ([#10207](https://github.com/facebook/jest/pull/10207))
910
- `[jest-fake-timers]` Lazily instantiate mock timers ([#10551](https://github.com/facebook/jest/pull/10551))
1011
- `[jest-runtime]` `require.main` is no longer `undefined` when using `jest.resetModules` ([#10626](https://github.com/facebook/jest/pull/10626))
1112
- `[@jest/types]` Add missing values for `timers` ([#10632](https://github.com/facebook/jest/pull/10632))

docs/Configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ If the value is `modern`, [`@sinonjs/fake-timers`](https://github.com/sinonjs/fa
12231223

12241224
### `transform` [object\<string, pathToTransformer | [pathToTransformer, object]>]
12251225

1226-
Default: `{"^.+\\.[jt]sx?$": "babel-jest"}`
1226+
Default: `{"\\.[jt]sx?$": "babel-jest"}`
12271227

12281228
A map from regular expressions to paths to transformers. A transformer is a module that provides a synchronous function for transforming source files. For example, if you wanted to be able to use a new language feature in your modules or tests that aren't yet supported by node, you might plug in one of many compilers that compile a future version of JavaScript to a current one. Example: see the [examples/typescript](https://github.com/facebook/jest/blob/master/examples/typescript/package.json#L16) example or the [webpack tutorial](Webpack.md).
12291229

@@ -1238,7 +1238,7 @@ You can pass configuration to a transformer like `{filePattern: ['path-to-transf
12381238

12391239
_Note: a transformer is only run once per file unless the file has changed. During the development of a transformer it can be useful to run Jest with `--no-cache` to frequently [delete Jest's cache](Troubleshooting.md#caching-issues)._
12401240

1241-
_Note: when adding additional code transformers, this will overwrite the default config and `babel-jest` is no longer automatically loaded. If you want to use it to compile JavaScript or Typescript, it has to be explicitly defined by adding `{"^.+\\.[jt]sx?$": "babel-jest"}` to the transform property. See [babel-jest plugin](https://github.com/facebook/jest/tree/master/packages/babel-jest#setup)_
1241+
_Note: when adding additional code transformers, this will overwrite the default config and `babel-jest` is no longer automatically loaded. If you want to use it to compile JavaScript or Typescript, it has to be explicitly defined by adding `{"\\.[jt]sx?$": "babel-jest"}` to the transform property. See [babel-jest plugin](https://github.com/facebook/jest/tree/master/packages/babel-jest#setup)_
12421242

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

docs/Webpack.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ _Note: if you are using babel-jest with additional code preprocessors, you have
125125

126126
```json
127127
"transform": {
128-
"^.+\\.js$": "babel-jest",
129-
"^.+\\.css$": "custom-transformer",
128+
"\\.js$": "babel-jest",
129+
"\\.css$": "custom-transformer",
130130
...
131131
}
132132
```

e2e/__tests__/__snapshots__/showConfig.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ exports[`--showConfig outputs config info and exits 1`] = `
6767
"timers": "real",
6868
"transform": [
6969
[
70-
"^.+\\\\.[jt]sx?$",
70+
"\\\\.[jt]sx?$",
7171
"<<REPLACED_JEST_PACKAGES_DIR>>/babel-jest/build/index.js",
7272
{}
7373
]

e2e/coverage-remapping/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"jest": {
33
"rootDir": "./",
44
"transform": {
5-
"^.+\\.(ts|js)$": "<rootDir>/typescriptPreprocessor.js"
5+
"\\.(ts|js)$": "<rootDir>/typescriptPreprocessor.js"
66
},
77
"testEnvironment": "node"
88
},

e2e/coverage-transform-instrumented/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"jest": {
33
"rootDir": "./",
44
"transform": {
5-
"^.+\\.(js)$": "<rootDir>/preprocessor.js"
5+
"\\.(js)$": "<rootDir>/preprocessor.js"
66
},
77
"testRegex": "/__tests__/.*\\.(js)$",
88
"testEnvironment": "node",

e2e/global-setup-custom-transform/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"testEnvironment": "node",
44
"globalSetup": "<rootDir>/setup.js",
55
"transform": {
6-
"^.+\\.js$": "<rootDir>/transformer.js"
6+
"\\.js$": "<rootDir>/transformer.js"
77
}
88
}
99
}

e2e/node-path/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"jest": {
33
"testEnvironment": "node",
44
"transform": {
5-
"^.+\\.jsx?$": "../../packages/babel-jest"
5+
"\\.jsx?$": "../../packages/babel-jest"
66
}
77
}
88
}

e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"jest": {
33
"transform": {
4-
"^.+\\.js$": "<rootDir>/../packages/babel-jest"
4+
"\\.js$": "<rootDir>/../packages/babel-jest"
55
},
66
"testEnvironment": "node",
77
"testPathIgnorePatterns": [

e2e/snapshot-serializers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"jest": {
33
"testEnvironment": "node",
44
"transform": {
5-
"^.+\\.js$": "<rootDir>/transformer.js"
5+
"\\.js$": "<rootDir>/transformer.js"
66
},
77
"snapshotSerializers": [
88
"./plugins/foo",

0 commit comments

Comments
 (0)