React Testing: JSX error diffs

Share this video with your friends

Send Tweet

When writing React component tests, it can be hard to decipher the error diffs of broken tests, since they are just the final objects that React uses under the hood. There are some nice libraries that let you extend your assertion library to show JSX diffs; in this lesson we will wire up one of these libraries to show how to debug JSX error diffs from your React tests. We will also show how narrowing down what you are testing helps to make the test error diffs easier to deal with.

NOTE: This lesson uses the expect-jsx package, but there are other options available for both expect and other assertion libraries.

squirm-life
squirm-life
~ 9 years ago

My problem was directly related to a version issue. I am using 0.13.3.

tnl-matt
tnl-matt
~ 6 years ago

In React 16, import TestUtils from 'react-dom/test-utils';