Snapshot Test

Noun · Development

Definitions

  1. An automated test that captures the serialized output of a component or function (such as rendered HTML or a JSON structure), saves it to a file, and on subsequent runs compares the current output to the stored snapshot — failing if anything has changed unexpectedly. Popularized by Jest for React component testing.

    In plain English: A test that takes a picture of your code's output and alerts you if the output ever changes from what was previously saved.

    Example: "The snapshot test caught that someone accidentally changed the modal's class names — just run jest --updateSnapshot if the change is intentional."

Related Terms