Skip to content

Commit 0c5f68b

Browse files
AtofStrykerdominicfraser
andauthoredSep 18, 2023
fix: unsafe-to-chain-command: Fix the false positive of 'focus' regex 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>
1 parent 0a3bd81 commit 0c5f68b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

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

+1-1
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

+9
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)
Please sign in to comment.