You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run Jest once with --no-cache to see if that fixes the problem you are experiencing. : Yes
Do you want to request a feature or report a bug? bug
What is the current behavior?
In the documentation for mockRejectedValue, it states that it is a sugar function to mockImplementation(() => Promise.reject(value)), however as can be seen in the repl.it demo below, it is not. mockRejectedValue assumes that the rejection is handled immediately in the current event loop cycle, if it is not, it will cause the test to fail even though the rejection is handled in later cycles.
Repro repl.it demo. Although the documentation say it's only available in 22.2.0+ and repl.it's jest version is 22.1.2, I have tried it locally with 22.4.2 and I am seeing the same issue.
What is the expected behavior?
Follow what the documentation states, "Simple sugar function for: jest.fn().mockImplementationOnce(() => Promise.reject(value));".
Run npx envinfo --preset jest in your project directory and paste the
results here
System:
OS: Windows 10
CPU: x64 Intel(R) Xeon(R) CPU E5-1650 v3 @ 3.50GHz
Binaries:
Node: 9.4.0
Yarn: 1.3.2
npm: 5.6.0
The text was updated successfully, but these errors were encountered:
rongduan-zhu
changed the title
mockRejectedValue is not a sugar function to mockImplementation
mockRejectedValue is not a sugar function to mockImplementation(() => Promise.reject(value))
Mar 21, 2018
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.
--no-cache
to see if that fixes the problem you are experiencing. : YesDo you want to request a feature or report a bug?
bug
What is the current behavior?
In the documentation for
mockRejectedValue
, it states that it is a sugar function tomockImplementation(() => Promise.reject(value))
, however as can be seen in the repl.it demo below, it is not.mockRejectedValue
assumes that the rejection is handled immediately in the current event loop cycle, if it is not, it will cause the test to fail even though the rejection is handled in later cycles.Repro
repl.it demo. Although the documentation say it's only available in
22.2.0+
and repl.it'sjest
version is22.1.2
, I have tried it locally with22.4.2
and I am seeing the same issue.What is the expected behavior?
Follow what the documentation states, "Simple sugar function for:
jest.fn().mockImplementationOnce(() => Promise.reject(value));
".Please provide your exact Jest configuration
Run
npx envinfo --preset jest
in your project directory and paste theresults here
The text was updated successfully, but these errors were encountered: