-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[jest-mock] Return value is not recorded if mock implementation throws an error #5761
Comments
I thought of this while lying in bed this morning, then discovered that my previous PR had already been merged :( I'll create a new PR for this in the next day or two. It also got me thinking that it would be nice to also maintain an array of errors thrown by calls to the mock. Any objections to including this new feature at the same time? |
Great preemptive find @UselessPickles |
@rickhanlonii Thanks. Does this balance out my bad karma for introducing the bug in the first place? @SimenB Do you want to be involved with this issue since you reviewed my previous PR for this feature? |
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. |
Do you want to request a feature or report a bug?
Bug in new feature that I created :(
What is the current behavior?
If a jest mock function throws an error, the
.mock.returnValues
array is not updated with an entry for that call to the mock. This causes thereturnValues
array to become out of sync with all other parallel arrays in the structure (calls
,instances
, etc).Original new feature ticket: #5738
Original new feature PR: #5752
If the current behavior is a bug, please provide the steps to reproduce
Should be obvious. I'll add a new unit test to reproduce it before fixing it.
What is the expected behavior?
The the parallel arrays in the mock function's
mock
structure should always have matching lengths. When a mock function implementation throws an error, a value ofundefined
should be pushed onto themock.returnValues
array.Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
Irrelevant
The text was updated successfully, but these errors were encountered: