diff --git a/src/rules/__tests__/prefer-expect-assertions.test.ts b/src/rules/__tests__/prefer-expect-assertions.test.ts index 6e56295ec..ceee711b1 100644 --- a/src/rules/__tests__/prefer-expect-assertions.test.ts +++ b/src/rules/__tests__/prefer-expect-assertions.test.ts @@ -816,6 +816,20 @@ ruleTester.run('prefer-expect-assertions (callbacks)', rule, { `, options: [{ onlyFunctionsWithExpectInCallback: true }], }, + { + code: dedent` + it('is a test', () => { + expect(expected).toBe(actual); + }); + + describe('my test', () => { + it('is another test', () => { + expect(expected).toBe(actual); + }); + }); + `, + options: [{ onlyFunctionsWithExpectInCallback: true }], + }, ], invalid: [ { diff --git a/src/rules/prefer-expect-assertions.ts b/src/rules/prefer-expect-assertions.ts index 1b73fe8b4..99ca8a770 100644 --- a/src/rules/prefer-expect-assertions.ts +++ b/src/rules/prefer-expect-assertions.ts @@ -178,6 +178,8 @@ export default createRule<[RuleOptions], MessageIds>({ return; } + inTestCaseCall = false; + if (node.arguments.length < 2) { return; }