-
Notifications
You must be signed in to change notification settings - Fork 469
poc for getting/querying by title #34
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
One more thing! In the react-testing-library I just add custom selectors as I go, some for a high level functionality (like this - getByTitle, or getByValue), some for higher level ( getDeleteTodo ), it works beautifully and seamlessly, but when I go to cypress I can't reuse them. It would be nice to expose this: Is this something you would be willing to take a PR for? |
No, I think those are ok, if that's what the design calls for 👌 I'm in favor of adding this query 👍
Yep, feel free to open a PR |
Cool, thanks! Next one I needed to add manually that seems universal was getByValue. What do you think about that one? In case of that specific rewrite I'm doing - all the listed todos are inputs with values. They get automatically updated when you click and change their value. unfortunately, getByText doesn't work in that case. Using placeholder doesn't make too much sense - it would have to be generic ("todo") instead of the specific todo text. And, obviously, I'd rather not add testids there, since all I have is already visible from the point of view of the user :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is great 👏
Thanks so much for your help! I've added you as a collaborator on the project. Please make sure that you review the |
🎉 This PR is included in version 1.11.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Thanks @kentcdodds ! I think you missed my comment by accident - what would you think about a similar PR for getByValue (reasons in the comment above)? |
Yes, I suppose a getByValue also makes sense. In general, I'm in favor of selectors that resemble how users find elements on the page, or (less optimal) how screen readers find elements on a page. |
What:
Add ability to get/query by title, basic test coverage for now
Why:
Here comes my question, I've been seeing this pattern quite a bit:
https://github.com/meteor/todos/blob/react/imports/ui/components/ListHeader.jsx#L162
I wanted to learn your thinking here - are those antipatterns? I'm rewriting above example app by the Meteor guys to Apollo backend/frontend, while using cypress-testing-library and react-testing-library to drive the work.
I'm not sure if I have any other way of accessing elements like that.
I could rewrite places like that to use img with alt instead, but I'm trying to keep the components as similar to the original ones as possible (so it will be easier to compare between meteor and apollo)
How:
Checklist: