DOM Matchers - Styling and Attributes

When testing your React applications, you will often need to check that a rendered HTML element has a specific attribute, class name, or inline style.

Note: There are other related helpers for form elements (like asserting the current value on a input field) - these are covered in an upcoming lesson.

Lesson covers:

toHaveAttribute, toHaveClass, toHaveStyle

Read on to find out how to use these features in React Testing Library.

Loading full lesson content & code...

Ready to try running tests for this lesson?