auto-spies
auto-spies copied to clipboard
Code inside async method with 'await [...].toPromise' stops execution
Describe the bug When .toPromise is called on a spied on method with a .nextWith the code stops execution
To Reproduce Steps to reproduce the behavior:
- In the test call nextWith on a spied on method
- The spied on method is called with as
await <<spy>>.<<method>>.toPromise()
inside an async method - Step through
- The next line in the method never gets hit and no errors are caught
Expected behavior When called as toPromise() the observable should be cast as a Promise and when awaited should return the current value. Then jest debugger should not stop execution of the method and continue stepping through the code on the next line.
Screenshots
Desktop (please complete the following information):
- OS: OSX Mojave
- Browser Jest Test Runner running in VS Code
- Version
Additional context Package json version info:
"@angular/core": "13.2.2",
"jest-auto-spies": "^1.6.6",
AFAIK- toPromise
waits for the observable to be completed before resolving.
nextWith
keeps the observable open.
Try using nextOneTimeWith
instead, as it completes after sending the value.. it should solve your issue
Let me know if you run into any other issues
@brinehart Did you have success with the suggested solution/other feedback?
If not I suggest closing this issue now.