Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Issue with webpack #37

Open
OpakAlex opened this issue Sep 24, 2015 · 9 comments
Open

Issue with webpack #37

OpakAlex opened this issue Sep 24, 2015 · 9 comments

Comments

@OpakAlex
Copy link

ERROR in ./~/mockery/mockery.js
Module not found: Error: Cannot resolve module 'module' in /private/var/www/coders51/mta-components/node_modules/mockery
 @ ./~/mockery/mockery.js 39:8-25

Any ideas? Thanks!

@OpakAlex
Copy link
Author

@mfncooper i need your help :)

@at0g
Copy link

at0g commented Sep 30, 2015

me too

@davglass
Copy link
Collaborator

davglass commented Oct 6, 2015

Sorry, I didn't see this. I've never attempted to use mockery in the browser, is that what you are trying to do? mockery is designed to only work in Node as it uses a lot of the core Node infrastructure under the hood to mock the require statements which are not the same as the ones in the browser.

@at0g
Copy link

at0g commented Oct 10, 2015

@davglass Thanks for your reply, I understand that require in the browser does not make.
My build was targeting node using common js 2 (no UMD).
Specifically I was creating a [node] bundle for testing with mocha cli and wanted to use mockery to mock deps.

@sheepsteak
Copy link

I've managed to mock modules using inject-loader (https://github.com/plasticine/inject-loader) before in Webpack.

@Primajin
Copy link

@sheepsteak Can you explain how you got this to run with mockery in webpack? I am not able to extrapolate from the readme.md of inject-loader onto how to inject mockery into webpack.

@sheepsteak
Copy link

@Primajin I just used inject-loader instead of mockery. If you don't want to do that you could just run your tests outside of webpack with the mocha/jasmine CLI.

@Primajin
Copy link

@sheepsteak ohhh instead! Thanks I was totally confused 😉

@theKashey
Copy link

There is a mocking library with mockery-compatible API, which can handle webpack as well -> https://github.com/theKashey/rewiremock

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants