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

Warn or error when stubbing non-existent functions #234

Open
tstackhouse opened this issue Jan 21, 2019 · 1 comment
Open

Warn or error when stubbing non-existent functions #234

tstackhouse opened this issue Jan 21, 2019 · 1 comment

Comments

@tstackhouse
Copy link

This is great tool for writing my tests, however I've noticed that both with and without noCallThru(), if we stub a library and write out our test cases, if the underlying module methods then change, our test cases continue to work, even though the underlying methods have changed. The running code would obviously break, but the tests seems to behave just fine.

Would it be possible to warn or even fail when stubbing functions on require()'d modules that don't actually exist?

@bendrucker
Copy link
Collaborator

Possible? Yeah.

It feels like two things are in conflict here. If you want to use noCallThru to ensure that your stub will be passed exactly instead of merged into the original module, proxyquire doesn't load your original module. To get errors about differences between your stub and the original module, you'd have to load the original. So this definitely doesn't fit into noCallThru. Maybe it could fit in with callThru, namely offering an option to throw if any key in the stub is not present on the original.

It's going to be tricky to shoehorn this into the current API but I'm happy to hear any thoughts if you have them on how we might do it.

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