Nullean.Snapshots
0.5.0
See the version list below for details.
dotnet add package Nullean.Snapshots --version 0.5.0
NuGet\Install-Package Nullean.Snapshots -Version 0.5.0
<PackageReference Include="Nullean.Snapshots" Version="0.5.0" />
<PackageVersion Include="Nullean.Snapshots" Version="0.5.0" />
<PackageReference Include="Nullean.Snapshots" />
paket add Nullean.Snapshots --version 0.5.0
#r "nuget: Nullean.Snapshots, 0.5.0"
#:package Nullean.Snapshots@0.5.0
#addin nuget:?package=Nullean.Snapshots&version=0.5.0
#tool nuget:?package=Nullean.Snapshots&version=0.5.0
<p align="center"> <a href="https://snapshots.nullean.net"> <picture> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/nullean/snapshots/main/docs/images/brand/png/lockup-light.png"> <img src="https://raw.githubusercontent.com/nullean/snapshots/main/docs/images/brand/png/lockup.png" alt="snapshots." width="276" height="96"> </picture> </a> </p>
<p align="center"><strong>Structural Snapshot tests for .NET</strong></p>
<p align="center"> <a href="https://www.nuget.org/packages/Nullean.Snapshots.AwesomeAssertions"><img alt="NuGet" src="https://img.shields.io/nuget/v/Nullean.Snapshots.AwesomeAssertions?color=9fc9ea&label=nuget"></a> <a href="https://github.com/nullean/snapshots/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/nullean/snapshots/actions/workflows/ci.yml/badge.svg"></a> <a href="https://snapshots.nullean.net"><img alt="Docs" src="https://img.shields.io/badge/docs-snapshots.nullean.net-c6dd7a"></a> </p>
Nullean.Snapshots is snapshot testing on AwesomeAssertions for text, HTML, JSON,
YAML, PNG images, browser journeys and HTTP responses. A test's output is compared with a verified file kept with your
tests, or with a string literal right in the test (inline snapshots); when it differs, the test fails with
a short, plain message that says exactly what moved and how to accept it. A small native AOT CLI, snap, reviews and
accepts what changed.
[Test]
public void Serializes() =>
catalog.Should().MatchJsonSnapshot(AppJsonContext.Default.Catalog);
JSON did not match snapshot: tests/Shop.Tests/.snapshots/CatalogTests/Serializes.verified.json
3 difference(s):
$.items[0].name expected "kibana" actual "Kibana" (verified.json:5:15)
$.items[1] missing in actual (verified.json:7:5)
$.extra unexpected in actual
Received: .artifacts/.snapshots/received/Shop.Tests/CatalogTests/Serializes.received.json
Accept: snap accept Shop.Tests/CatalogTests/Serializes (or: dnx Nullean.Snapshots.Cli accept Shop.Tests/CatalogTests/Serializes)
How it works
- Compared by structure, not by text. HTML compares as a DOM; JSON and YAML compare as trees. Attribute order,
whitespace, key order and
1versus1.0do not fail a test, and a changed field is reported by its path, with the line and column in the verified file. Images compare by their pixels, perceptually and with anti-aliasing left out, so a screenshot passes on every machine. - Verified files, or the value right in the test. Short values can be inline snapshots:
MatchInlineSnapshot("""…""")keeps the expected value as a string literal, and accepting rewrites that literal. - Messages people and agents can act on. Plain text without colour codes, repository-relative paths, at most 20 differences and 80 lines, and the exact command to accept. They read the same in a terminal, a CI log and an agent's context.
- You accept, or nothing changes. Nothing is ever accepted for you.
SNAPSHOT_ACCEPT=1works on your machine; withCIset it is ignored, and the failure says so. - Tidy. Verified files live in one
.snapshots/folder per test project, mirroring your test files. Received files go toobj/or your artifacts folder, never into source. - Lightweight. Every package is trimming- and native-AOT-safe, the core has no heavy dependencies, and every write goes through a file system scoped to the snapshot folders.
Packages
| Package | For |
|---|---|
Nullean.Snapshots |
the core: the snapshot store, accept modes, scrubbers, the line and tree differs and the failure messages; the other packages build on it |
Nullean.Snapshots.AwesomeAssertions |
Should().MatchSnapshot() and MatchInlineSnapshot() for text, and the base the format packages build on |
Nullean.Snapshots.Html |
MatchHtmlSnapshot, MatchInlineHtmlSnapshot, BeHtml, ContainHtml, NotContainHtml; select, remove and transform first |
Nullean.Snapshots.Json |
MatchJsonSnapshot and MatchInlineJsonSnapshot for JSON text and objects (AOT-safe through JsonTypeInfo<T>), BeJson |
Nullean.Snapshots.Yaml |
MatchYamlSnapshot, MatchInlineYamlSnapshot, BeYaml; the YAML 1.2 core schema, anchors and merge keys, stored as written |
Nullean.Snapshots.Images |
MatchImageSnapshot for PNG screenshots; compared by pixels, with a diff image on failure |
Nullean.Snapshots.Browser |
browser journeys: agent-browser commands run in Chrome with Nullean.Cdp, each read compared as a tree (JourneySnapshot, snap journey run) |
Nullean.Snapshots.Browser.Assertions |
MatchJourneySnapshot and MatchAriaSnapshot for AwesomeAssertions |
Nullean.Snapshots.Http |
HTTP responses and .http files run with Nullean.HttpFileParser: status, chosen headers and JSON bodies compared as trees, secrets redacted (HttpSnapshot, HttpFileSnapshot, snap http run) |
Nullean.Snapshots.Http.Assertions |
MatchHttpSnapshot, MatchHttpFileSnapshot and HttpFileTest for AwesomeAssertions |
Nullean.HttpFileParser |
parses, lints and runs .http files on its own, with no dependency on the snapshot packages; the portable subset of the Visual Studio, REST Client and JetBrains dialects |
Nullean.Snapshots.TUnit |
the running TUnit test's class, method and arguments, so every case gets its own file |
Nullean.Snapshots.Cli |
snap: review, diff, accept, reject, and find orphaned snapshots; accepting an inline snapshot rewrites the literal in the test; snap journey run and snap http run check journeys and .http files without a test run |
Getting started
<PackageReference Include="Nullean.Snapshots.AwesomeAssertions" Version="0.*" />
<PackageReference Include="Nullean.Snapshots.Json" Version="0.*" />
<PackageReference Include="Nullean.Snapshots.TUnit" Version="0.*" />
dotnet tool install --global Nullean.Snapshots.Cli
snap # walk through what changed: accept, reject or skip each snapshot
The first run of a new snapshot fails and writes a received file. Read it, accept it with snap accept <key> (or
snap review), and commit the verified file. From then on a change in output is a decision you make with the
difference in front of you.
Read more at snapshots.nullean.net: the formats, the snap workflow,
snapshots in CI, working with coding agents, and the reference.
Versions are 0.x while the API settles. The packages need .NET 10.
Contributing
See AGENTS.md for conventions, DECISIONS.md for the choices behind the design and
ROADMAP.md for the plan. scripts/docs.sh builds and serves the documentation locally, given a
docs-builder binary.
License
MIT, see LICENSE.txt.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- DiffPlex (>= 1.9.0)
- Nullean.ScopedFileSystem (>= 0.5.0)
- System.IO.Abstractions (>= 22.3.0)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on Nullean.Snapshots:
| Package | Downloads |
|---|---|
|
Nullean.Snapshots.AwesomeAssertions
Snapshot assertions for AwesomeAssertions: value.Should().MatchSnapshot(). |
|
|
Nullean.Snapshots.TUnit
TUnit test identity for Nullean.Snapshots: the runtime class, method and arguments of the running test. |
|
|
Nullean.Snapshots.Html
HTML snapshots and inline HTML assertions for Nullean.Snapshots: pretty-printed with AngleSharp, compared structurally with AngleSharp.Diffing. |
|
|
Nullean.Snapshots.Json
JSON snapshots and inline JSON assertions for Nullean.Snapshots, compared as trees: key order ignored, numbers by value, differences by path. |
|
|
Nullean.Snapshots.Yaml
YAML snapshots and inline YAML assertions for Nullean.Snapshots: stored verbatim, compared as trees with the YAML 1.2 core schema, differences pointing at line and column. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.13.0 | 0 | 11/14/2026 |
| 0.12.2 | 52 | 11/14/2026 |
| 0.12.1 | 150 | 11/12/2026 |
| 0.12.0 | 174 | 11/12/2026 |
| 0.11.0 | 264 | 11/11/2026 |
| 0.10.1 | 185 | 11/11/2026 |
| 0.10.0 | 155 | 11/11/2026 |
| 0.9.0 | 119 | 11/11/2026 |
| 0.8.1 | 213 | 11/11/2026 |
| 0.8.0 | 199 | 11/11/2026 |
| 0.7.0 | 301 | 11/10/2026 |
| 0.6.0 | 333 | 11/5/2026 |
| 0.5.0 | 193 | 11/5/2026 |
| 0.4.0 | 642 | 11/5/2026 |
| 0.3.0 | 193 | 11/4/2026 |
| 0.2.0 | 516 | 11/3/2026 |
| 0.1.0 | 581 | 11/3/2026 |
| 0.1.0-alpha.1 | 86 | 11/3/2026 |