Test Enzyme Rendered Components with Jest Snapshots

Share this video with your friends

Send Tweet

In this lesson we will utilize Jest's snapshot testing to make sure our component's rendered output stays consistent. Unit testing the component elements can take us far, however sometimes it is helpful to test the entire component interface.

Krishna Pradhan
Krishna Pradhan
~ 7 years ago

Hi Tyler after adding the npm "enzyme-to-json"

the test suite failed with this message Cannot find module 'enzyme-adapter-react-16' from 'App.test.js'

Damian Joniec
Damian Joniec
~ 5 years ago

My snapshot looks like that, not like yours full of text , is that correct: // Jest Snapshot v1, https://goo.gl/fbAQLP

exports[<App /> matches the snapshot 1] = ShallowWrapper {};

Ahmed Soliman
Ahmed Soliman
~ 5 years ago

Can we use .debug() from enzyme instead of enzyme-to-json ?