Search⌘ K

Use Testing Library

Explore how to use Testing Library with Cypress to write tests that closely reflect how users interact with web applications. Understand how to configure Testing Library, write accessible tests using roles, and improve confidence in your app's behavior and accessibility.

Testing library

The more your tests resemble the way your software is used, the more confidence they can give you.

Testing Library provides a way to write your tests so that they represent how the users actually use the web application. Let’s look at an example we currently have in the services/web/cypress/integration/spec.js file:

it("has the correct <h1>", () => {
  cy.contains("h1", "Great success!");
});

This test looks for a “heading 1” element and validates that its content is “Great success!”. From a developer’s perspective, this ...