Description
Update: @modernserf is working on a PR to this issue. Please don't submit other PRs.
Currently, create-react-app allows you to structure your app like this:
node_modules/
└─ react/
src/
├─ __tests__/
├─ index.js
└─ node_modules/
└─ @myapp/
├─ foo/
└─ bar/
So you can import 3rd party modules with import "react"
or local modules with import "@myapp/foo"
. Webpack will preprocess the files in src/node_modules
, es6 features (including imports) are converted with babel. I imagine this behavior is intentional, because typical babel-loader configurations ignore all node_modules
directories.
However, although Webpack will preprocess these files through Babel, Jest will not; if your tests imports one of these local modules, Jest will choke on the un-transpiled import
statements.
I think all one needs to do to enable this is add preprocessorIgnorePatterns: ["<rootDir>/node_modules"]
to the Jest config -- this will continue to not preprocess regular node_modules, but will preprocess internal node_modules, so it should have no impact on existing apps.