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

[no-standalone-expect]: false positive on expect.<method>() #1186

Closed
mrtnzlml opened this issue Aug 7, 2022 · 4 comments · Fixed by #1191
Closed

[no-standalone-expect]: false positive on expect.<method>() #1186

mrtnzlml opened this issue Aug 7, 2022 · 4 comments · Fixed by #1191

Comments

@mrtnzlml
Copy link
Contributor

mrtnzlml commented Aug 7, 2022

Hey, I received an update with the latest version 26.8.0 (adeira/universe#4859); however, it seems to be throwing false errors:

Screen Shot 2022-08-07 at 15 07 21

To my knowledge, addSnapshotSerializer should be outside of the test block (see: https://jestjs.io/docs/expect#expectaddsnapshotserializerserializer). Is my code wrong? Is this a bug in the latest release? 🤔

Thanks for having a look! 😎

@G-Rath G-Rath changed the title 26.8.0: invalid "Expect must be inside of a test block" [no-standalone-expect]: incorrect "Expect must be inside of a test block" on expect.addSnapshotSerializer Aug 8, 2022
@G-Rath
Copy link
Collaborator

G-Rath commented Aug 8, 2022

Per my comment here, I think we should probably change no-standalone-expect to only care about expect.hasAssertions & expect.assertions

@G-Rath G-Rath changed the title [no-standalone-expect]: incorrect "Expect must be inside of a test block" on expect.addSnapshotSerializer [no-standalone-expect]: false positive on expect.<method>() Aug 8, 2022
@G-Rath
Copy link
Collaborator

G-Rath commented Aug 8, 2022

I'm going to change the logic tomorrow to what I said in my last comment - I should be able to get this landed tomorrow morning (NZST)

@alopix
Copy link

alopix commented Aug 8, 2022

Saw the same behaviour for expect.extend() which you would definitely expect to call outside of a test block—specifically in the global jest setup.

@github-actions
Copy link

github-actions bot commented Aug 8, 2022

🎉 This issue has been resolved in version 26.8.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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