Fill: toMatchSnapshot
Fill in the Blank Medium
Question
Fill in the blank to use snapshot testing:
Code
test('snapshot', () => {
expect({ name: 'Alice' }).___();
});
Hint
The matcher name includes 'Snapshot'.
Explanation
The correct answer is toMatchSnapshot. This matcher captures the value on the first run and saves it to a snapshot file. On subsequent runs, it compares the current value to the saved snapshot and fails if they differ.
Related Resources
Related Lessons
- Snapshot Testing
Using snapshots effectively.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.