-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Having the following structure:
- MyModule
| - MyDependency
| - MyLibrary
| - MyDependency
When MyLibrary requires MyDependency, it loads it from MyModule/node_modules/MyLibrary/node_modules folder if it's available, when it should get the peer version.
The problem that this issue arises is an inconsistent behaviour when using local linked packages, because when installing through yarn install MyLibrary won't contain a node_modules folder, but when doing through yarn link MyLibrary it will, as it's a soft link.
In my case, MyDependency is rx, and MyLibrary creates a Reactive extension by defining some methods on Rx.Observable.prototype. When running jest without any local link, or when through nodejs, this works properly, but when running through jest with MyLibrary locally linked, Rx.Observable.prototype gets wiped when rx is loaded a second time.
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
https://github.com/voliva/jestpeer
You must locally link the modules by:
> cd MyDep; yarn link; cd ..
> cd MyLib; yarn link MyDep; yarn link; cd ..
> cd MyModule; yarn; yarn link MyDep; yarn link MyLib;
If you run yarn start, that's just node running the app, you should get:
MyDep run/load C:\Users\victor\Documents\development\jestpeer\MyDep
MyLib run/load C:\Users\victor\Documents\development\jestpeer\MyLib
MyModule run/load C:\Users\victor\Documents\development\jestpeer\MyModule
Done in 0.27s.
If you run yarn test, that's jest running the test, you should get:
Ran all test suites.
console.log node_modules\MyLib\node_modules\MyDep\index.js:1
MyDep run/load C:\Users\victor\Documents\development\jestpeer\MyModule\node_modules\MyLib\node_modules\MyDep
console.log node_modules\MyLib\index.js:3
MyLib run/load C:\Users\victor\Documents\development\jestpeer\MyModule\node_modules\MyLib
console.log node_modules\MyDep\index.js:1
MyDep run/load C:\Users\victor\Documents\development\jestpeer\MyModule\node_modules\MyDep
console.log index.js:4
MyModule run/load C:\Users\victor\Documents\development\jestpeer\MyModule
Done in 3.23s.
Notice how while when running through node MyLib doesn't get loaded twice, while when running through Jest it does
What is the expected behavior?
yarn test should output
Ran all test suites.
console.log node_modules\MyDep\index.js:1
MyDep run/load C:\Users\victor\Documents\development\jestpeer\MyModule\node_modules\MyDep
console.log node_modules\MyLib\index.js:3
MyLib run/load C:\Users\victor\Documents\development\jestpeer\MyModule\node_modules\MyLib
console.log index.js:4
MyModule run/load C:\Users\victor\Documents\development\jestpeer\MyModule
Done in 3.23s.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Default jest configuration, Jest 18.0.0, node 6.9.1, yarn 0.19.0, Windows 10 64bit.