Get Started
| Product | Versions |
|---|---|
| .NET |
README
Nullean.Snapshots

The core of Nullean.Snapshots, structural snapshot tests for .NET: the snapshot store, accept modes, scrubbers, the line and tree differs and the failure messages. Tests normally use it through Nullean.Snapshots.AwesomeAssertions or a format package; reference it directly to configure scrubbers or to build your own assertion.
Install
dotnet add package Nullean.Snapshots
Quick start
Scrub volatile values for every snapshot, once, before tests run, and build an assertion on the store:
using System.Runtime.CompilerServices;
using Nullean.Snapshots;
internal static class SnapshotSetup
{
[ModuleInitializer]
internal static void Init()
{
SnapshotDefaults.AddScrubber(Scrubbers.Guids); // Guid_1, Guid_2, ...
SnapshotDefaults.AddScrubber(Scrubbers.DateTimes); // DateTime_1, ...
}
}
public static class MyAssertions
{
// Your own assertion on top of the store: the key comes from the call site.
public static void MatchMySnapshot(
this string actual,
[CallerFilePath] string file = "",
[CallerMemberName] string member = "",
[CallerLineNumber] int line = 0)
{
var result = Snapshot.Match(actual, SnapshotFormats.Text, new SnapshotCallSite(file, member, line));
if (!result.Passed)
throw new InvalidOperationException(result.FailureMessage);
}
}
How it behaves
- A new snapshot fails: with no verified file the test fails and writes a received file. Accept it with
snap accept <key>(theNullean.Snapshots.Clitool) after reading it. SNAPSHOT_ACCEPT=1accepts every mismatch in the run. WithCIset to1ortrueit is ignored, and the failure message says so.- Verified files:
.snapshots/<test file dir>/<Class>/<Method>[.<name>][.<argsHash>].verified.<ext>; commit them. Received files go to$(ArtifactsPath)/.snapshots/received/<Project>/..., elseobj/snapshots/received/. - No scrubber runs by default. Global scrubbers run before per-call ones
(
new SnapshotOptions().Scrub(regex, replacement)). - Text is stored as UTF-8 without BOM, LF endings and one trailing newline.
Learn more
- Documentation: https://snapshots.nullean.net
- Layout of snapshot files: https://snapshots.nullean.net/reference/layout/
- Options: https://snapshots.nullean.net/reference/options/
- Source and issues: https://github.com/nullean/snapshots
Downloads by Version
Similar & Alternative Packages
Hand-picked matching NuGet libraries based on tags & ecosystem
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.