Skip to content

Commit

Permalink
Merge pull request #141 from gkorakas-eli/fix/issue-with-unsafe-to-ch…
Browse files Browse the repository at this point in the history
…ain-command-that-is-not-action

fix: issue with unsafe to chain command that is not an action
  • Loading branch information
jennifer-shehane authored May 3, 2024
2 parents 87f35e0 + 3f22c8e commit dc22026
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -130,7 +130,7 @@ const isRootCypress = (node) => {
*/
const isActionUnsafeToChain = (node, additionalMethods = []) => {
const unsafeActionsRegex = new RegExp([
...unsafeToChainActions,
...unsafeToChainActions.map((action) => `^${action}$`),
...additionalMethods.map((method) => method instanceof RegExp ? method.source : method),
].join('|'))

Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/unsafe-to-chain-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ ruleTester.run('action-ends-chain', rule, {
code: 'cy.focused().should("be.visible");',
parserOptions,
},
{
code: 'cy.submitBtn().click();',
parserOptions,
},
],

invalid: [
Expand Down

0 comments on commit dc22026

Please sign in to comment.