Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue with unsafe to chain command that is not an action #141

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}$`),
gkorakas-eli marked this conversation as resolved.
Show resolved Hide resolved
...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