Skip to content
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

Add data-testid as a type of selector #256

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tommy-gilligan
Copy link

Marking up components with data-testid is a pretty popular way of providing somewhat namespaced access to DOM for the purpose of testing. Other testing tools have support for data-testid but I'll admit it's somewhat arbitrary as a selector and I appreciate that we probably want to keep By::{X, Y, Z} to a minimum. Feel free to reject PR on those grounds.

Creating my own helpers outside of thirtyfour does work mostly fine except when it comes to creating Component with macros. Typing out #[by(css = "[data-testid=\"confirmation-confirm\"]")] feels somewhat cumbersome. That's really the motivation for this PR.

I've gone with referring to data-testid as Testid in Rust code. (nb. lowercase i). This feels weird but reflects the commonly used casing when adding testids in markup.

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.

1 participant