Skip to content

Commit e97395d

Browse files
huy-nguyencpojer
authored andcommitted
Improve TS instructions (jestjs#3414)
The regex for TS transformer in the doc is too broad. For example, I set the regex to `".(ts|tsx)"` as recommended in the docs and my test would fail. The reason is that one of my tested file imports the file `isArguments.js` from `lodash-es` (ES 2015 build of lodash). Because `isArguments.js` matches the pattern `.(ts|tsx)`, this file is not transpiled by babel (even after I've set `transformIgnorePatterns` to `"<rootDir>/node_modules/(?!lodash-es)"`. Changing the pattern to `"^.+\\.tsx?$"` fixes this problem.
1 parent 057ba3a commit e97395d

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

ā€ŽREADME.mdā€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ then modify your `package.json` so the `jest` section looks something like:
116116
{
117117
"jest": {
118118
"transform": {
119-
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
119+
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
120120
},
121121
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
122122
"moduleFileExtensions": [

ā€Ždocs/en/GettingStarted.mdā€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ then modify your `package.json` so the `jest` section looks something like:
120120
{
121121
"jest": {
122122
"transform": {
123-
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
123+
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
124124
},
125125
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
126126
"moduleFileExtensions": [

0 commit comments

Comments
Ā (0)
⚔