JavaScript › Debugging, Testing & Tooling
What is snapshot testing and what's a common pitfall with it?
AdvancedAnswer
Snapshot testing saves a serialized representation of a component/output and fails future test runs if the output changes unexpectedly. The pitfall is developers blindly running 'update snapshots' without reviewing the diff, which silently approves real regressions.
expect(renderComponent(<Button label='Save' />)).toMatchSnapshot();Real-world example Catching accidental UI markup changes in a design-system component library.