A failing snapshot is regenerated with -u, and after the third time that becomes reflex — at which point the test asserts that the output equals whatever the output currently is.
// a snapshot of a whole tree: fails on any change, explains none
expect(render(<Checkout />)).toMatchSnapshot();
// an assertion about behaviour: fails when behaviour changes
expect(screen.getByRole('button', { name: /pay/i })).toBeEnabled();
expect(onSubmit).toHaveBeenCalledWith({ amount: 4900 });
Snapshots are genuinely useful for small, stable, serialisable values — a formatter’s output, a reducer’s next state — and poor for a component tree that changes for cosmetic reasons weekly. The rule worth adopting is that a snapshot must be small enough to read in the diff; anything larger than a screen has stopped being a test and become a record. --ci in the pipeline refuses to write new snapshots, which catches the ones nobody committed.