Skip to content

.tip

· one of the small things

Snapshots for output you would diff by eye, nothing else

A snapshot of a whole React tree changes on every refactor and gets updated without anyone reading it. A snapshot of a generated SQL statement, an email body or an error message is something a reviewer really does check in the diff.

expect(buildQuery(filters)).toMatchInlineSnapshot(`"SELECT … WHERE status = $1"`);

Inline snapshots keep the expectation next to the test. If you can't tell from the diff whether a snapshot change is right, it should be an assertion.

testing