Skip to content

docs: add custom queries example to custom render docs #152

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

Conversation

kierenhughes
Copy link
Contributor

@kierenhughes kierenhughes commented Jun 20, 2019

Following on from my previous PR (#151) and having noticed the discussion in #80:

  • Adding an example for adding custom queries globally via creating a custom render function.

In the example, I've create a data attribute selector for data-cy as this is one of the attributes recommended by Cypress. I think in reality I would favour replacing data-cy globally throughout my projects with data-testid, but this may be useful for some people not willing to refactor out data-cy, or similar, at the moment.

@kierenhughes kierenhughes force-pushed the docs/add-custom-render-queries-example branch 3 times, most recently from 54d7850 to 259fbf9 Compare June 20, 2019 12:02
@kierenhughes kierenhughes force-pushed the docs/add-custom-render-queries-example branch from 259fbf9 to f46aaf8 Compare June 20, 2019 19:53
@kierenhughes kierenhughes force-pushed the docs/add-custom-render-queries-example branch from f46aaf8 to f059027 Compare June 20, 2019 20:23
@kierenhughes kierenhughes force-pushed the docs/add-custom-render-queries-example branch 4 times, most recently from fbd51ee to 7dc39ba Compare June 21, 2019 07:43
@alexkrolick
Copy link
Collaborator

Should probably explain a little what "cy" stands for but other than that LGTM

@kierenhughes kierenhughes force-pushed the docs/add-custom-render-queries-example branch 2 times, most recently from 516945a to 5f81c5e Compare June 23, 2019 09:39
@kierenhughes
Copy link
Contributor Author

@alexkrolick

Should probably explain a little what "cy" stands for but other than that LGTM

I've added a bit about that along with the link to the relevant Cypress.io docs regarding selecting by data-*.

I've also added a recommendation around not needing to use your own queries and only doing so if your queries encourage testing in a user-centric way without focusing on implementation details.

@kierenhughes kierenhughes force-pushed the docs/add-custom-render-queries-example branch from 5f81c5e to cea8057 Compare June 23, 2019 11:24
@alexkrolick alexkrolick merged commit d0e92f8 into testing-library:master Jun 23, 2019
@alexkrolick
Copy link
Collaborator

@all-contributors please add @kierenhughes for docs

@allcontributors
Copy link
Contributor

@alexkrolick

I've put up a pull request to add @kierenhughes! 🎉

@kierenhughes kierenhughes deleted the docs/add-custom-render-queries-example branch June 23, 2019 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants