Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: trying to merge Functional base with callThrough mock at ${path} Use overrideBy #38

Closed
dewhacker opened this issue Aug 24, 2018 · 2 comments

Comments

@dewhacker
Copy link

dewhacker commented Aug 24, 2018

Getting this error when attempting to mock a local module:
rewiremock('../path/to/my/module') .callThrough() .with({'./another/local/module':stub});
What is overrideBy and when should it be used?

@dewhacker
Copy link
Author

I resolved this by using this syntax instead:
rewiremock.around( () => require('../path/to/my/module'), rewiremock('../another/local/module').with(stub) );
Not exactly sure why that worked though?

@theKashey
Copy link
Owner

overrideBy is just .by(anotherModule)
The error is about using callThrough for an module with a "non-object" export - look like it exports just a function.

PS

rewiremock.around(
 () => require('../path/to/my/module'),  
 () => rewiremock('../another/local/module').with(stub) // this should be a function call
);

// you can use .proxy to do the same
rewiremock.proxy('../path/to/my/module', {
 '../another/local/module': stub
});

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

No branches or pull requests

2 participants