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 for expect.any in __mocks__ file #1189

Closed
garyking opened this issue Aug 8, 2022 · 3 comments · Fixed by #1191
Closed

[no-standalone-expect]: false positive for expect.any in __mocks__ file #1189

garyking opened this issue Aug 8, 2022 · 3 comments · Fixed by #1191

Comments

@garyking
Copy link
Contributor

garyking commented Aug 8, 2022

I have a file in __mocks__ called twitch-js-api.js and I'm using the following:

const formatStreams = jest.fn().mockReturnValue([
  {
    channel: {
      logo: expect.any(String)
    }
  }
])

Yet this rule now warns on expect.any(String)? Isn't expect allowed in mock files? This code has worked for years.

@G-Rath
Copy link
Collaborator

G-Rath commented Aug 8, 2022

Technically the rule is correct, and the fact that it wasn't erroring before was arguably a bug but I'm thinking maybe we should actually ignore except member calls except for hasAssertions and assertions as everything is valid to be used outside of test blocks 🤔

@G-Rath G-Rath changed the title jest/no-standalone-expect even for expect used in a __mocks__ file? [no-standalone-expect]: false positive for expect.any in __mocks__ file Aug 8, 2022
@G-Rath
Copy link
Collaborator

G-Rath commented Aug 8, 2022

I'm going to close this as a duplicate of #1186

@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
2 participants