Snapshot Tests
Learn to use snapshots to test data outputs.
We'll cover the following
Snapshot testing is a technique we can use to test functions that return some large or complex data. Suppose we want to test the full HTML rendered by a large component. We could record a copy of the entire HTML returned by the function. Then, we can make an expectation that the function in our test should always return the same data.
This technique can be helpful to quickly write tests for complex data, such as JSON or HTML. This is often much easier than making expectations about each piece of data we expect to see in the output. On the other hand, it can be quite inflexible. Every time the data changes, we need to update our snapshot.
Get hands-on with 1400+ tech skills courses.