diff --git a/lib/rules/unsafe-to-chain-command.js b/lib/rules/unsafe-to-chain-command.js index 9fce903e..712bef6a 100644 --- a/lib/rules/unsafe-to-chain-command.js +++ b/lib/rules/unsafe-to-chain-command.js @@ -19,7 +19,7 @@ const unsafeToChainActions = [ 'check', 'dblclick', 'each', - 'focus$', + 'focus', 'rightclick', 'screenshot', 'scrollIntoView', @@ -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('|')) diff --git a/tests/lib/rules/unsafe-to-chain-command.js b/tests/lib/rules/unsafe-to-chain-command.js index c79b8e6e..470bebd5 100644 --- a/tests/lib/rules/unsafe-to-chain-command.js +++ b/tests/lib/rules/unsafe-to-chain-command.js @@ -18,6 +18,10 @@ ruleTester.run('action-ends-chain', rule, { code: 'cy.focused().should("be.visible");', parserOptions, }, + { + code: 'cy.submitBtn().click();', + parserOptions, + }, ], invalid: [