Thought leadership from the most innovative tech companies, all in one place.

How to Print the Entire Component Using screen.debug() in React Testing Library

I love React Testing Library and if you’re here, you probably love it too.

But when we’re testing a component with many lines of JSX and trying to print it, React Testing Library will not show the entire component.

Problem

// Problem 🔴screen.debug()

Solution

Luckily, the solution to this problem is straightforward, the following command will print the whole component in the console.

screen.debug(undefined, Infinity);

Source




Continue Learning