Use data-testid Attributes to Combat Brittle Tests
Learn how to deal with brittle tests in our Rails application.
We'll cover the following
The tags used in our view are currently semantically correct, and thus, our tests can safely rely on that. However, these semantics might change without affecting the way the page actually works. Suppose we want a new message, “Widget Information,” on the page as the most important thing. That means our widget name should no longer be an <h1>
, but instead an <h2>
.
Here’s the change to update the view:
Get hands-on with 1200+ tech skills courses.