Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #607
Closed
Open
Issue created Sep 08, 2016 by Administrator@rootContributor

Allow Jest to preprocess non-root node_modules

Created by: modernserf

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.

Update: @modernserf is working on a PR to this issue. Please don't submit other PRs.

Assignee
Assign to
Time tracking