Skip to content

Commit f725f55

Browse files
committed
feat: apply no-pause rule recursively
1 parent abb8591 commit f725f55

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

lib/rules/no-pause.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ module.exports = {
3535
}
3636

3737
function isCypressCall (node) {
38-
return node.callee &&
39-
node.callee.type === 'MemberExpression' &&
40-
node.callee.object.type === 'Identifier' &&
41-
node.callee.object.name === 'cy'
38+
if (!node.callee || node.callee.type !== 'MemberExpression') {
39+
return false;
40+
}
41+
if (node.callee.object.type === 'Identifier' && node.callee.object.name === 'cy') {
42+
return true;
43+
}
44+
return isCypressCall(node.callee.object);
4245
}
43-
46+
4447
//----------------------------------------------------------------------
4548
// Public
4649
//----------------------------------------------------------------------

tests/lib/rules/no-pause.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@ const ruleTester = new RuleTester()
2020
ruleTester.run('no-pause', rule, {
2121

2222
valid: [
23-
// for now, we do not detect .pause() child command
24-
{ code: `cy.get('button').pause()`, parserOptions },
2523
{ code: `pause()`, parserOptions },
2624
{ code: `cy.get('button').dblclick()`, parserOptions },
2725
],
28-
26+
2927
invalid: [
3028
{ code: `cy.pause()`, parserOptions, errors },
3129
{ code: `cy.pause({ log: false })`, parserOptions, errors },
30+
{ code: `cy.get('button').pause()`, parserOptions, errors },
31+
{
32+
code: `cy.get('a').should('have.attr', 'href').and('match', /dashboard/).pause()`,
33+
parserOptions,
34+
errors
35+
}
3236
],
3337
})

0 commit comments

Comments
 (0)