How to print the entire component using screen.debug() in React Testing Library?
·1 min
I love React Testing Library and if you’re here you 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.
// Solution ✅
screen.debug(undefined, Infinity)