Skip to content

Commit c48a099

Browse files
committed
feat: apply no-pause rule recursively
1 parent 8227cbc commit c48a099

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
@@ -33,12 +33,15 @@ module.exports = {
3333
}
3434

3535
function isCypressCall (node) {
36-
return node.callee &&
37-
node.callee.type === 'MemberExpression' &&
38-
node.callee.object.type === 'Identifier' &&
39-
node.callee.object.name === 'cy'
36+
if (!node.callee || node.callee.type !== 'MemberExpression') {
37+
return false;
38+
}
39+
if (node.callee.object.type === 'Identifier' && node.callee.object.name === 'cy') {
40+
return true;
41+
}
42+
return isCypressCall(node.callee.object);
4043
}
41-
44+
4245
//----------------------------------------------------------------------
4346
// Public
4447
//----------------------------------------------------------------------

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)