Skip to content

Commit

Permalink
fix: unsafe-to-chain-command: Fix the false positive of 'focus' regex…
Browse files Browse the repository at this point in the history
… matching 'focused' (#144)

* fix(pencil): illustrate the false positive of 'focus' regex matching 'focused'

* add test to ensure 'focus' does fail, in addition to 'focused' passing

---------

Co-authored-by: Dominic Fraser <dominic.fraser@skyscanner.net>
  • Loading branch information
AtofStryker and dominicfraser committed Sep 18, 2023
1 parent 0a3bd81 commit 0c5f68b
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
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
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 0c5f68b

Please sign in to comment.