testing-library-printing-large-dom-trees

2020-09-10

 | 

~1 min read

 | 

119 words

With some regularity when debugging my tests, I’d be confounded by a trimmed output for my debug statement. I could usually work around this by increasing the specificity of what I was investigating. Sometimes however, that’s a pain and I’d prefer to have a solution that “just works.”

You know you hit the limit when you see the ... in the console printout. Fortunately, there’s a workaround. testing-library will look for an environment variable DEBUG_PRINT_LIMIT. The default is 7000. To change your setting, set the variable in your terminal session prior to running tests:

DEBUG_PRINT_LIMIT=10000 npm test

Alternatively, you can use a .env file and update your script to source that first. See Sourcing Variables for more.



Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!