From ec83eb0a27ea68aceca1ff182d9ae2c931df1d83 Mon Sep 17 00:00:00 2001 From: mikiher Date: Mon, 29 Apr 2024 08:03:10 +0300 Subject: [PATCH] Add support for cy.get("&id") (translates to [cy-id="id"]) --- client/cypress/support/commands.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/cypress/support/commands.js b/client/cypress/support/commands.js index 66ea16ef..80348c92 100644 --- a/client/cypress/support/commands.js +++ b/client/cypress/support/commands.js @@ -22,4 +22,10 @@ // // // -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) \ No newline at end of file +// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) +Cypress.Commands.overwriteQuery('get', function (originalFn, ...args) { + if (args.length > 0 && typeof args[0] === 'string' && args[0].startsWith('&')) { + args[0] = `[cy-id="${args[0].substring(1)}"]` + } + return originalFn.apply(this, args) +}) \ No newline at end of file