Skip to content

Commit d5b89f4

Browse files
author
Ben M
authored
Merge pull request #142 from dominicfraser/chain_command_focused_false_positive
unsafe-to-chain-command: Fix the false positive of 'focus' regex matching 'focused'
2 parents b9f7a26 + 0c525e1 commit d5b89f4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/rules/unsafe-to-chain-command.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const unsafeToChainActions = [
1919
'check',
2020
'dblclick',
2121
'each',
22-
'focus',
22+
'focus$',
2323
'rightclick',
2424
'screenshot',
2525
'scrollIntoView',

tests/lib/rules/unsafe-to-chain-command.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ ruleTester.run('action-ends-chain', rule, {
1414
code: 'cy.get("new-todo").type("todo A{enter}"); cy.get("new-todo").type("todo B{enter}"); cy.get("new-todo").should("have.class", "active");',
1515
parserOptions,
1616
},
17+
{
18+
code: 'cy.focused().should("be.visible");',
19+
parserOptions,
20+
},
1721
],
1822

1923
invalid: [
@@ -27,6 +31,11 @@ ruleTester.run('action-ends-chain', rule, {
2731
parserOptions,
2832
errors,
2933
},
34+
{
35+
code: 'cy.get("new-todo").focus().should("have.class", "active");',
36+
parserOptions,
37+
errors,
38+
},
3039
{
3140
code: 'cy.get("new-todo").customType("todo A{enter}").customClick();',
3241
parserOptions,

0 commit comments

Comments
 (0)