Skip to content

Commit

Permalink
Improve TS instructions (jestjs#3414)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
huy-nguyen authored and cpojer committed May 2, 2017
1 parent 057ba3a commit e97395d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ then modify your `package.json` so the `jest` section looks something like:
{
"jest": {
"transform": {
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
Expand Down
2 changes: 1 addition & 1 deletion docs/en/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ then modify your `package.json` so the `jest` section looks something like:
{
"jest": {
"transform": {
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
Expand Down

0 comments on commit e97395d

Please sign in to comment.