Which selectors your choose for your tests matter, a lot. In this lesson, we'll see the recommended Cypress best practices for selectors, and why we should prefer the data-cy attribute.
Recommended Homework:
I'm getting Error: CypressError: Timed out retrying: Expected to find element: 'Hello world', but never found it.
for some reason. Haven't looked into it as this probably isn't a feature I would use, but just a heads up
why not to use id attribute?
It is good to be intentional, data attributes for testing are easy to identify and are less likely to be miss used by someone looking to attach JavaScript behaviour or CSS to an element. And they can be changed with a higher certainty that they will not break anything un-intentionally.