I'm working on a React web app that uses a component library we include as an npm module. Because I'm working on the library and the webapp at the same time, I linked the library as module in npm.
The directories are set up like this:
~/Development/
|
|-- myWebapp/
| |-- package.json # (react included here as dependency)
| |-- src/
| |-- node_modules/
| |-- jest-cli/
| |-- react/
| |-- myLibrary/ -> /usr/local/lib/node_modules/myLibrary
|
|-- myLibrary/ # (linked to /usr/local/lib/node_modules by npm link)
| |-- package.json
| |-- src/
| |-- node_modules/
| |-- react/ # (included as a devDependency and peerDependency)
I'm writing my tests in Jest (0.8.2).
I'm trying to configure Jest to not load React from myLibrary/node_modules/react when I run tests for myWebapp. Loading React twice tends to cause problems. My tests pass if I rm -r myLibrary/node_modules/react
before I run them, but it's a pain to uninstall and reinstall React all the time.
I tried to configure Jest with:
...,
"modulePathIgnorePatterns": [
"<rootDir>/node_modules/myLibrary/node_modules/react"
],
...
but that did not seem to work