Skip to content

Commit

Permalink
fix(expect-expect): don't error on it.todo & test.todo calls (#954)
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath authored Oct 15, 2021
1 parent 34cdbe0 commit d3cc0db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/rules/__tests__/expect-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const ruleTester = new TSESLint.RuleTester({

ruleTester.run('expect-expect', rule, {
valid: [
'it.todo("will test something eventually")',
'test.todo("will test something eventually")',
"['x']();",
'it("should pass", () => expect(true).toBeDefined())',
'test("should pass", () => expect(true).toBeDefined())',
Expand Down
8 changes: 8 additions & 0 deletions src/rules/expect-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
createRule,
getNodeName,
getTestCallExpressionsFromDeclaredVariables,
isSupportedAccessor,
isTestCaseCall,
} from './utils';

Expand Down Expand Up @@ -116,6 +117,13 @@ export default createRule<
isTestCaseCall(node) ||
additionalTestBlockFunctions.includes(name)
) {
if (
node.callee.type === AST_NODE_TYPES.MemberExpression &&
isSupportedAccessor(node.callee.property, 'todo')
) {
return;
}

unchecked.push(node);
} else if (matchesAssertFunctionName(name, assertFunctionNames)) {
// Return early in case of nested `it` statements.
Expand Down

0 comments on commit d3cc0db

Please sign in to comment.