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

expect.hasAssertions() triggered in different test #4496

Closed
a-omsk opened this issue Sep 17, 2017 · 3 comments · Fixed by #4498
Closed

expect.hasAssertions() triggered in different test #4496

a-omsk opened this issue Sep 17, 2017 · 3 comments · Fixed by #4498

Comments

@a-omsk
Copy link

a-omsk commented Sep 17, 2017

Hello, i found some bug while i use expect.hasAssertions || expect.assertions in async it().

My case:

https://github.com/a-omsk/x-task/blob/master/__tests__/components/Pipe.test.js

if i try to insert expect.hasAssertions() in first it() case i catch the error in next it(), but i have no any expect.hasAssertions() in second it()

 FAIL  __tests__/components/Pipe.test.js
  ● Pipe › should sequentially do the tasks passed as children

    expect.hasAssertions()

    Expected at least one assertion to be called but received none. 

My jest version: 21.0.1

@thymikee
Copy link
Collaborator

Checked out your project, installed with yarn, added expect.hasAssertions() and the test passes. So cannot repro. Closing.

@thymikee
Copy link
Collaborator

Actually, there's indeed a bug. .hasAssertions holds global state without resetting, so it leaks to all other test blocks.

@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
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants