Skip to content

[max-expects] false positive in helper function declared after the test body #1205

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

Closed
spdiswal opened this issue Aug 21, 2022 · 1 comment · Fixed by #1206
Closed

[max-expects] false positive in helper function declared after the test body #1205

spdiswal opened this issue Aug 21, 2022 · 1 comment · Fixed by #1206

Comments

@spdiswal
Copy link

Assertion calls in helper functions seem to count toward the limit of max-expects when the function is declared after the test body, even if it is not called by the test body.

Reproduction: https://github.com/spdiswal/eslint-plugin-jest-max-expects

test("foo", function () {
  expectNonNullString("hello world")
  expect(true).toBe(true)
})

test("bar", function () {
  expect(true).toBe(true)
  expect(true).toBe(true)
  expect(true).toBe(true)
  expect(true).toBe(true)
  expect(true).toBe(true)
})

function expectNonNullString(obj) {
  expect(obj).not.toBe(null)
  expect(typeof obj).toBe("string")
}
  15:2  error  Too many assertion calls (6). Maximum allowed is 5  jest/max-expects
  16:2  error  Too many assertion calls (7). Maximum allowed is 5  jest/max-expects
@github-actions
Copy link

🎉 This issue has been resolved in version 26.8.6 🎉

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