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

Code inside async method with 'await [...].toPromise' stops execution #65

Open
brinehart opened this issue Jul 14, 2022 · 2 comments
Open

Comments

@brinehart
Copy link

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:

  1. In the test call nextWith on a spied on method
  2. The spied on method is called with as await <<spy>>.<<method>>.toPromise() inside an async method
  3. Step through
  4. 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
Screen Shot 2022-07-14 at 10 21 36 AM

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",
@shairez
Copy link
Member

shairez commented Jul 19, 2022

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

@hlovdal
Copy link

hlovdal commented Jan 10, 2023

@brinehart Did you have success with the suggested solution/other feedback?

If not I suggest closing this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants