See my blog post at https://tobiasmaier.info:
UI testing plays a crucial role in ensuring that our applications work correctly and consistently. Traditionally, people either matched strings, referenced CSS classes or element IDs. But the landscape of UI testing is shifting, introducing a new and improved approach:
data-testid
.This blog post explains how to use Test IDs with RSpec and Capybara, and introduces two new RSpec matchers (
have_test_id
andhave_test_id_and_css
) to simplify UI testing.
Source: https://tobiasmaier.info/posts/2023/06/19/rspec-capybara-data-testid.html