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

Add a way to verify that a mocked require was not interacted with. #109

Closed
iamrandys opened this issue Aug 5, 2014 · 3 comments
Closed

Comments

@iamrandys
Copy link

I have test code that verifies that there was no interaction with a mocked required dependency like the following.

    var mockedRequiredModule = require('../../my-module');

    // exercise a module that uses mockedRequiredModule

    // iterate over all mocked functions and make sure there was no interaction.
    _.values(mockedRequiredModule, function(mockedFunction) {
        expect(mockedFunction).not.toBeCalled();
    });

It would be nice to replace this code with something that is easier to understand. Something like:

expect(mockedRequiredModule).not.toHaveHadInteraction();
@ghost
Copy link

ghost commented Aug 4, 2015

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

@cpojer
Copy link
Member

cpojer commented Mar 3, 2016

You can add this using jest.addMatchers and custom Jasmine matchers yourself, see jasmine.github.io/2.0/custom_matcher.html :)

Feel free to publish it as a jest extension and I'll mention it on the website.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants