New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUERY] Can multiple test-ids be configured? #155
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hi John, Unfortunately I don't think this is possible. But you could make your own command for those. And here's the CODE_OF_CONDUCT.md file: https://github.com/testing-library/cypress-testing-library/blob/master/other/CODE_OF_CONDUCT.md Thanks! |
Thanks @kentcdodds Do you have time to create and share an example of how to create a command to configre multiple test-id attributes? |
Hi @JohnJacobT, I don't have a lot of time, but take this for example: cy.get('[mydata-testid="example"]') That should get you an element with that attribute/value pair. From there you could paramarize it and make it a custom command: Cypress.Commands.add('getByMyTestId', id => cy.get(`[mydata-testid="${id}"]`))
// then later
cy.getByMyTestId('example') I hope that helps! Good luck! |
Got the idea. Thanks again! |
Hello,
First of all, thank you for creating this.
This is not a 'issue', but a query: Can you configure more than one testid attribute?
The section Configure testId attribute shows how to change the default testId attribute to another. Is it possible to configure multiple testid attributes, if yes, how?
Cypress documentation about Selector Playground talks about different testid attributes in the order of priority. In a couple of projects, I am working on, I see different testId attributes used in different sections of a web app. With these two, I assume, it is not uncommon to encounter different test id attributes in the same web app. Hence the question.
In case, configuring multiple test id attributes are not currently supported, is there a plan to incorporate this feature in later releases?
Regards,
John.
P.S - CODE_OF_CONDUCT.md, mentioned in the template that comes up while creating a new issue, is not found in this repository.
The text was updated successfully, but these errors were encountered: