Skip to main content
net10.0

PNG image snapshots for Nullean.Snapshots: decoded with its own PNG codec and compared pixel by pixel, perceptually and with anti-aliasing left out, so they pass on every machine.

Published
Nov 3, 2026
19d ago
Total Downloads
3.4K
3,437

Install

dotnet add package Nullean.Snapshots.Images --version 0.2.0
ProductVersions
.NET
net10.0

README

Structural Snapshot tests for .NET


Nullean.Snapshots is snapshot testing on AwesomeAssertions for text, HTML, JSON, YAML and PNG images. A test's output is compared with a verified file kept with your tests; 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 1 versus 1.0 do 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.
  • 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=1 works on your machine; with CI set 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 to obj/ 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.AwesomeAssertions Should().MatchSnapshot() for text, and the base the format packages build on
Nullean.Snapshots.Html MatchHtmlSnapshot, BeHtml, ContainHtml, NotContainHtml; select, remove and transform first
Nullean.Snapshots.Json MatchJsonSnapshot for JSON text and objects (AOT-safe through JsonTypeInfo<T>), BeJson
Nullean.Snapshots.Yaml MatchYamlSnapshot, 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.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

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.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.