Skip to content

Commit

Permalink
Add support for cy.get("&id") (translates to [cy-id="id"])
Browse files Browse the repository at this point in the history
  • Loading branch information
mikiher committed Apr 29, 2024
1 parent 6236f53 commit ec83eb0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
// 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)
})

0 comments on commit ec83eb0

Please sign in to comment.