Skip to content

Commit

Permalink
feat: apply no-pause rule recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
tom9744 committed May 3, 2024
1 parent abb8591 commit f725f55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 8 additions & 5 deletions lib/rules/no-pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ module.exports = {
}

function isCypressCall (node) {
return node.callee &&
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
node.callee.object.name === 'cy'
if (!node.callee || node.callee.type !== 'MemberExpression') {
return false;
}
if (node.callee.object.type === 'Identifier' && node.callee.object.name === 'cy') {
return true;
}
return isCypressCall(node.callee.object);
}

//----------------------------------------------------------------------
// Public
//----------------------------------------------------------------------
Expand Down
10 changes: 7 additions & 3 deletions tests/lib/rules/no-pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ const ruleTester = new RuleTester()
ruleTester.run('no-pause', rule, {

valid: [
// for now, we do not detect .pause() child command
{ code: `cy.get('button').pause()`, parserOptions },
{ code: `pause()`, parserOptions },
{ code: `cy.get('button').dblclick()`, parserOptions },
],

invalid: [
{ code: `cy.pause()`, parserOptions, errors },
{ code: `cy.pause({ log: false })`, parserOptions, errors },
{ code: `cy.get('button').pause()`, parserOptions, errors },
{
code: `cy.get('a').should('have.attr', 'href').and('match', /dashboard/).pause()`,
parserOptions,
errors
}
],
})

0 comments on commit f725f55

Please sign in to comment.