Writing tests

edit

A snapshot test is a regular test that ends with Snapshot.Validate. These pages describe what you pass to it, where the snapshots are stored and how to keep them stable from one run to the next.

  • Snapshot types: store a value as text, JSON, SVG, PNG or any other format, and how each format is compared.
  • Snapshot files: where the verified and actual files are stored, how their names are built, and how to store them in git and keep them out of the build.
  • Naming snapshots: several assertions in one test, parameterized tests, naming strategies and the test context.
  • Helper methods: wrap Snapshot.Validate in your own assertion methods.
  • Deterministic snapshots: scrub GUIDs, dates, user and machine names, and control line endings and invisible characters.
  • Asynchronous values: validate a stream or an asynchronous sequence without blocking the test, and cancel the read.