Created
August 9, 2021 12:55
-
-
Save gioragutt/0ca66eb09f11eff2f84e5e3dad714337 to your computer and use it in GitHub Desktop.
cy.tid(...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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