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

mockImplementationOnce doesn't mock constructor, mockImplementation does #4595

Closed
ashfurrow opened this issue Oct 4, 2017 · 1 comment · Fixed by #4599
Closed

mockImplementationOnce doesn't mock constructor, mockImplementation does #4595

ashfurrow opened this issue Oct 4, 2017 · 1 comment · Fixed by #4599
Labels

Comments

@ashfurrow
Copy link

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

So I noticed that when mocking constructors, mockImplementation() will work as I expect (it mocks the implementation), but calling mockImplementationOnce() does not mock the implementation.

You can see the bug here: https://repl.it/MCyG/3 if you change mockImplementationOnce in thing.test.js to mockImplementation, then the test will pass.

What is the expected behavior?

I would expect mockImplementationOnce to work like mockImplementation, except it only mocks it once.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

macOS 10.13, Jest 21.2.1, Yarn 0.24.5, Node 6.10.2.

@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 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants