Skip to content

Commit

Permalink
fix(prefer-explicit-assert): handle valid getBy* without expect (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
skovy committed Nov 18, 2020
1 parent e74c215 commit b289638
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rules/prefer-explicit-assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default ESLintUtils.RuleCreator(getDocsUrl)<Options, MessageIds>({
});
} else if (assertion) {
const expectCallNode = findClosestCallNode(node, 'expect');
if (!expectCallNode) return;

const expectStatement = expectCallNode.parent as TSESTree.MemberExpression;
const property = expectStatement.property as TSESTree.Identifier;
Expand Down
4 changes: 3 additions & 1 deletion tests/lib/rules/prefer-explicit-assert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ ruleTester.run(RULE_NAME, rule, {
code: `queryByText("foo")`,
},
{
code: `expect(getByText('foo')).toBeTruthy()`,
code: `expect(getByText('foo')).toBeTruthy()
fireEvent.click(getByText('bar'));`,
options: [
{
assertion: 'toBeTruthy',
Expand Down

0 comments on commit b289638

Please sign in to comment.