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

Published on

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

Enjoyed this article?

Share it with your network to help others discover it

Continue Learning

Discover more articles on similar topics