Enzyme debug() 🐞
Debugging React unit tests can be tricky. Today I learned about the Enzyme debug()
function. Here's the signature:
.debug([options]) => String
This function:
Returns an HTML-like string of the wrapper for debugging purposes. Useful to print out to the console when tests are not passing when you expect them to.
Using this in a log statement will dump a ton of valuable data into your test runner's output:
console.log(component.debug());
Tweet