# Testing Library

> Tools that test screens the way a person uses them, by labels and text.

**Field:** Software Development  
**Category:** Testing & Quality  
**Also known as:** React Testing Library, RTL, DOM Testing Library, @testing-library

## Think of it like

Think of it like testing a toy the way a child plays with it. You press the buttons a child would press.

## Definition

Testing Library is a set of tools for testing user interfaces the way people use them. Its rule is that tests should look like how the software is used. So it finds things by their role, label or text, not by hidden code names. There are versions for React, Vue, Angular and plain web pages. It runs inside test runners like Jest and Vitest.

## Example

Lucy's test finds the button named Log in, clicks it and checks a message appears. It does not care how the button is built.

## Example code

```jsx
render(<LoginForm />);
await userEvent.click(screen.getByRole("button", { name: "Log in" }));
expect(screen.getByText("Enter your email")).toBeInTheDocument();
```

Find the button by its name, click it, and look for the message.

## Why it matters

Tests keep passing when you rebuild a part, as long as users see the same thing.

## Common mistake

Finding elements by class names or test IDs first. Use roles and labels, the way users find them.

## Three principles

- **Like a user.** Find things by role and text.
- **Not the insides.** Ignore how a part is built.
- **Many frameworks.** React, Vue, Angular and more.

## Related terms

- [Jest](https://learn.benibix.com/term/development/jest)
- [Vitest](https://learn.benibix.com/term/development/vitest)
- [Unit Test](https://learn.benibix.com/term/development/unit-test)
- [React](https://learn.benibix.com/term/development/react)
- [Accessibility (a11y)](https://learn.benibix.com/term/design/accessibility)

![A table of test tools by job. Unit tests: Jest and Vitest for JavaScript, pytest for Python, JUnit for Java. UI components: Testing Library, which finds things the way a user does. Browser end-to-end tests, lit up: Cypress, Playwright and Selenium, which drive a real browser.](https://learn.benibix.com/diagrams/dev3-test-tools.svg)

---

Source: https://learn.benibix.com/term/development/testing-library
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
