Skip to content

Commit

Permalink
fix(valid-title): ensure argument node is defined before accessing pr…
Browse files Browse the repository at this point in the history
…ops (#538)
  • Loading branch information
G-Rath committed Feb 23, 2020
1 parent 5d8be9d commit 7730f75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/rules/__tests__/valid-title.test.ts
Expand Up @@ -271,6 +271,7 @@ ruleTester.run('no-empty-title', rule, {
'test(`${foo}`, function () {})',
'test.concurrent(`${foo}`, function () {})',
"it('foo', function () {})",
'it.each([])()',
"it.concurrent('foo', function () {})",
"xdescribe('foo', function () {})",
"xit('foo', function () {})",
Expand Down
6 changes: 5 additions & 1 deletion src/rules/valid-title.ts
Expand Up @@ -81,12 +81,16 @@ export default createRule({

return {
CallExpression(node: TSESTree.CallExpression) {
if (!(isDescribe(node) || isTestCase(node)) || !node.arguments.length) {
if (!isDescribe(node) && !isTestCase(node)) {
return;
}

const [argument] = getJestFunctionArguments(node);

if (!argument) {
return;
}

if (!isStringNode(argument)) {
if (
argument.type === AST_NODE_TYPES.BinaryExpression &&
Expand Down

0 comments on commit 7730f75

Please sign in to comment.