Unable to see the full DOM when `getByRole`/`getByText` fails

I use getByText/getByRole from the Testing Library in my test. When getByText/getByRole fails, I can only see part of the DOM being printed. How can I see the full DOM?

This is because the Testing Library prints no more than 7000 characters from a DOM by default:

Since the DOM size can get really large, you can set the limit of DOM content to be printed via environment variable DEBUG_PRINT_LIMIT. The default value is 7000.

You can make the Testing Library print a larger DOM by setting a high DEBUG_PRINT_LIMIT. For example:

DEBUG_PRINT_LIMIT=99999 npm run test

or add the following to your ~/.bashrc (for Bash) or ~/.zshrc (for Zsh):

export DEBUG_PRINT_LIMIT=99999