SnapshotAssertions 0.2.0
Prefix ReservedSee the version list below for details.
dotnet add package SnapshotAssertions --version 0.2.0
NuGet\Install-Package SnapshotAssertions -Version 0.2.0
<PackageReference Include="SnapshotAssertions" Version="0.2.0" />
<PackageVersion Include="SnapshotAssertions" Version="0.2.0" />
<PackageReference Include="SnapshotAssertions" />
paket add SnapshotAssertions --version 0.2.0
#r "nuget: SnapshotAssertions, 0.2.0"
#:package SnapshotAssertions@0.2.0
#addin nuget:?package=SnapshotAssertions&version=0.2.0
#tool nuget:?package=SnapshotAssertions&version=0.2.0
SnapshotAssertions
Scope: Test projects only. Not intended for production code.
Framework-agnostic core for text-snapshot assertions.
Most users want
SnapshotAssertions.TUnit, not this package directly. This is the shared engine; framework-specific adapter packages add the assertion entry points your test framework expects.
What's in this package
SnapshotComparer— string-against-file comparison with line-ending, BOM, trailing-whitespace, and trailing-newline options.SnapshotFileResolver— TestContext-aware default file naming (Snapshots/{TestClass}.{TestMethod}.expected.txt) and explicit-path resolution.SnapshotAcceptMode— env-var-driven accept logic (SNAPSHOT_ACCEPT=1writes the actual content over the expected baseline) with aCI=trueguard so accidental pipeline acceptance is impossible.SnapshotOptions— line-ending, BOM, whitespace, and trailing-newline configuration with strict defaults.LineDiffRenderer— terminal line-based diff display, truncated to the first 20 differing lines for very large diffs (LineDiffRenderer.MaxDifferingLines = 20).SnapshotScrubber+Scrubbersfactory (v0.2.0+) — text-transform pipeline that replaces volatile substrings (GUIDs, ISO 8601 timestamps, Unix-epoch-millis numbers, custom regex matches) with stable indexed tokens before comparison. Five built-ins (Scrubbers.Guid,Scrubbers.Iso8601Timestamp,Scrubbers.UnixEpochMillis, twoScrubbers.Patternoverloads), one curated chain (Scrubbers.Default), andSnapshotScrubberStatefor stable indexed-token assignment across recurring values.
Test-framework adapters
| Package | Test framework | Status |
|---|---|---|
SnapshotAssertions.TUnit |
TUnit | Available now |
SnapshotAssertions.NUnit |
NUnit | Possible if there is demand |
SnapshotAssertions.xUnit |
xUnit | Possible if there is demand |
SnapshotAssertions.MSTest |
MSTest | Possible if there is demand |
If you'd find a non-TUnit adapter useful, open a feature request — adapters are not built proactively.
Installation
dotnet add package SnapshotAssertions.TUnit
SnapshotAssertions comes transitively. You don't need to install it directly unless you're building your own adapter package.
Stability
The public surfaces above are semver-bound. Breaking changes require a major version bump. The exact text format of line-based diff output is not stable and may gain extra detail or change formatting in any release.
License
MIT — Copyright (c) 2026 John Verheij
| 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
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SnapshotAssertions:
| Package | Downloads |
|---|---|
|
SnapshotAssertions.TUnit
TUnit-native text-snapshot assertions using [AssertionExtension]. Provides Assert.That(actual).MatchesSnapshot() / .MatchesSnapshotFile() with line-based diff display, accept-via-environment-variable workflow, and CI guard. AOT-compatible, trimmable, no reflection. Designed for API-surface verification and small text snapshots; coexists with Verify for object-graph cases. |
GitHub repositories
This package is not used by any popular GitHub repositories.
See CHANGELOG.md