Skip to content

Commit

Permalink
Detect missing assertions in an arrow body (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanperret authored Aug 4, 2022
1 parent 214f366 commit 8c036c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/rules/missing-assertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ module.exports = {

let {callee} = expression;
checkCallee(callee, node);
}
},
ArrowFunctionExpression(node) {
if (
node.body && node.body.type === 'CallExpression' &&
node.body.callee
) {
checkCallee(node.body.callee, node.body);
}
},
};
}
};
11 changes: 10 additions & 1 deletion tests/lib/rules/missing-assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ ruleTester.run('missing-assertion', rule, {
return expect(true).to.be.ok();
});
`
}],
}, {
code: 'it("works as expected", () => expect(true).to.be.true);',
parserOptions: { ecmaVersion: 6 },
} ],

invalid: [{
code: `
Expand All @@ -49,5 +52,11 @@ ruleTester.run('missing-assertion', rule, {
errors: [{
message: 'expect(...) used without assertion'
}]
}, {
code: 'it("fails as expected", () => expect(true));',
parserOptions: { ecmaVersion: 6 },
errors: [{
message: 'expect(...) used without assertion'
}]
}]
});

0 comments on commit 8c036c8

Please sign in to comment.