From 93824e49b34db920a4ea83abbdcc60341550c175 Mon Sep 17 00:00:00 2001 From: George Korakas Date: Wed, 30 Aug 2023 13:40:32 +0300 Subject: [PATCH] fix: issue with unsafe to chain command that is not an action --- lib/rules/unsafe-to-chain-command.js | 2 +- tests/lib/rules/unsafe-to-chain-command.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rules/unsafe-to-chain-command.js b/lib/rules/unsafe-to-chain-command.js index ac2e13d3..82f1a8f1 100644 --- a/lib/rules/unsafe-to-chain-command.js +++ b/lib/rules/unsafe-to-chain-command.js @@ -129,7 +129,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 2855b59a..4c1a4bc1 100644 --- a/tests/lib/rules/unsafe-to-chain-command.js +++ b/tests/lib/rules/unsafe-to-chain-command.js @@ -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.submitBtn().click();', + parserOptions, + }, ], invalid: [