Testing Library Framework
testing-library.com
1
Leaving SiteNav
External Link Disclaimer
You are about to visit testing-library.com. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
Testing Library is a family of testing utilities created by Kent C. Dodds in 2018, providing lightweight solutions for testing web components and user interfaces by simulating how users interact with the application, querying elements by accessibility roles, text content, labels, and display values rather than implementation details like test IDs or CSS classes, encouraging better testing practices that focus on user behavior and accessibility, with adapter packages for React, Vue, Angular, Svelte, Preact, Solid, and Cypress, adopted by over eight million weekly npm users and by Google, Microsoft, and Meta for their component testing. The guiding philosophy is that tests should resemble how users interact with the application, meaning tests query for elements the way users find them through role-based queries that mirror accessibility tree structures, text-based queries that find visible text content, label queries that associate form fields with their labels, and display value queries that read input values, rather than testing implementation details that users never see like component state, internal methods, or CSS class names. The query hierarchy prioritizes queries from most to least accessible, with getByRole as the recommended top-level query that finds elements by their ARIA role and accessible name, followed by getByLabelText for form fields, getByPlaceholderText, getByText for buttons and links, getByDisplayValue for current input values, getByAltText for images, and getByTitle, with the testing discouraged for getByTestId as a last resort. The user events simulation through userEvent provides realistic interaction including typing, clicking, tabbing, selecting, hovering, pasting, and uploading, with realistic timing, focus management, and keyboard modifiers. The async utilities for testing dynamic content. The screen object for querying without container. The custom render for provider setup. Designed by Kent C. Dodds. Designed for frontend testing.
Statistics
1
Views
0
Clicks
0
Like
0
Dislike