theKashey / rewiremock

The right way to mock dependencies in Node.js or webpack environment.
MIT License
492 stars 30 forks source link

__mocks__ style mocking of organization modules #121

Open KristjanTammekivi opened 4 years ago

KristjanTammekivi commented 4 years ago

Hi, I want to use projectroot/mocks/@organization/module.js style mock but the getMockName seems to look for the mock inside node_modules/@organization/module/mocks

theKashey commented 4 years ago

https://github.com/theKashey/rewiremock/blob/b350aff1c4fe05d4329ca6f4e4033d29d240d794/src/plugins/__mock__.js#L11-L22 This moment should check more than one directory.

KristjanTammekivi commented 4 years ago

I added logging to autoMock to log out mockName if mockName includes our org name/package name and it only logged out /...project root.../node_modules/@ourorg/package/dist/mocks/index.js

theKashey commented 4 years ago

Yes. It is trying to resolve __mock__ only in one location, that's why you've created this issue. It can be fixed, but it is yet to fix.

Actually you can just reimplement this plugin in user space in a way it will work best for you, or wait a few days untill I'll get time to fix it.