Skip to content

Instantly share code, notes, and snippets.

@gioragutt
Created August 9, 2021 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gioragutt/0ca66eb09f11eff2f84e5e3dad714337 to your computer and use it in GitHub Desktop.
Save gioragutt/0ca66eb09f11eff2f84e5e3dad714337 to your computer and use it in GitHub Desktop.
cy.tid(...)
declare namespace Cypress {
interface Chainable {
tid: Cypress.Chainable['get'];
}
}
function attributeSelector(key: string, value: string) {
return `[${key}=${value}]`;
}
function tidSelector(testId: string) {
return attributeSelector('data-test-id', testId);
}
Cypress.Commands.add('tid', (testId: string, options?: Parameters<Cypress.Chainable['tid']>[1]) => {
return cy.get(tidSelector(testId), options);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment