You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But ESLint works properly when using an anonymous function instead of an arrow function...
it('my test description, function ({ expect }) {
// Now ESLint properly complainsconsta=1;constb=2;expect(sum(a,b)).toBe(a+b);})
Look at src/math.test.ts
There are two test cases. The first one is the one with the expect() method bound to the current context, but does not have a call to expect.assertions() or expect.hasAssertions(). Yet, npm run lint passes. The latter test case uses the expect() method imported from vitest, and has a call to expect.hasAssertions(). If removed, npm run lint will fail.
The text was updated successfully, but these errors were encountered:
Problem: If you have the
prefer-expect-assertions
rule enabled, and also have test like the following...ESLint fails to detect that
expect.assertions()
orexpect.hasAssertions()
is not present. I have an example repo here: https://github.com/ryanone/vitest-eslint-bugBut ESLint works properly when using an anonymous function instead of an arrow function...
src/math.test.ts
expect()
method bound to the current context, but does not have a call toexpect.assertions()
orexpect.hasAssertions()
. Yet,npm run lint
passes. The latter test case uses theexpect()
method imported from vitest, and has a call toexpect.hasAssertions()
. If removed,npm run lint
will fail.The text was updated successfully, but these errors were encountered: