Skip to content

Commit

Permalink
Merge pull request #142 from dominicfraser/chain_command_focused_fals…
Browse files Browse the repository at this point in the history
…e_positive

unsafe-to-chain-command: Fix the false positive of 'focus' regex matching 'focused'
  • Loading branch information
Ben M authored Sep 18, 2023
2 parents b9f7a26 + 0c525e1 commit d5b89f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/unsafe-to-chain-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const unsafeToChainActions = [
'check',
'dblclick',
'each',
'focus',
'focus$',
'rightclick',
'screenshot',
'scrollIntoView',
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/unsafe-to-chain-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ ruleTester.run('action-ends-chain', rule, {
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");',
parserOptions,
},
{
code: 'cy.focused().should("be.visible");',
parserOptions,
},
],

invalid: [
Expand All @@ -27,6 +31,11 @@ ruleTester.run('action-ends-chain', rule, {
parserOptions,
errors,
},
{
code: 'cy.get("new-todo").focus().should("have.class", "active");',
parserOptions,
errors,
},
{
code: 'cy.get("new-todo").customType("todo A{enter}").customClick();',
parserOptions,
Expand Down

0 comments on commit d5b89f4

Please sign in to comment.