Skip to content

Commit

Permalink
fix(prefer-expect-assertions): properly handle checking across multip…
Browse files Browse the repository at this point in the history
…le tests (#1089)
  • Loading branch information
G-Rath authored Apr 22, 2022
1 parent af2bdf9 commit 8b61b0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/rules/__tests__/prefer-expect-assertions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
2 changes: 2 additions & 0 deletions src/rules/prefer-expect-assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ export default createRule<[RuleOptions], MessageIds>({
return;
}

inTestCaseCall = false;

if (node.arguments.length < 2) {
return;
}
Expand Down

0 comments on commit 8b61b0c

Please sign in to comment.