Allow customization of Jest: transformIgnorePatterns
See original GitHub issueThere are a ton of issues about this, and after two hours of reading through them all, I still wasn’t able to get a sense of the state of things.
- It seems that some Jest config options are now available: https://github.com/facebookincubator/create-react-app/pull/1830
- Please make
transformIgnorePatterns
also available.
We have a case where we have local libraries that are brought into node_modules
, but then Jest stumbles whenever we import them, because it is not pre-processing the React components in node_modules
. Transpiling our components before export is not an option because the constant transpiling every time one makes a change is a serious drag on development.
Some discussion threw out symlinks
as a solution or workaround, but another developer on our team sunk many hours into that before finally getting stuck again.
There has to be a simple way to make LibraryA/MyReactComponent go into MyApp/node_modules, such that MyApp/src/MyComponent can import MyReactComponent during tests without any problems.
It would seem to be a common use case.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:12
- Comments:19 (7 by maintainers)
Top GitHub Comments
@Primajin @michaeldewolf85 @mandysimon88 It’s true that the
transformIgnorePatterns
option is currently not available via thejest
property inpackage.json
, however, you can still tap into Jest’s configuration options without ejecting using the CLI:Via the docs:
That last bit is what tipped me off (maybe a documentation improvement @gaearon). Obviously configuring Jest via
package.json
doesn’t work, and myjest.config.js
seemed to get trumped by CRA’s Jest config, so CLI args was the saving grace. Hope that helps!I have the same issue with an ejected app. Components in
node_modules
that need to be transpiled by Jest/Babel.I ended up changing
transformIgnorePatterns
to:["/node_modules/(?!(our-react-components-.*?\\.js$))"]
Now JS files in
our-react-components-*
folders innode_modules
are being transpiled.I understand the discussion is around a non-ejected app, I just wanted to give a solution to those that don’t mind ejecting.