aweXpect.Snapshots
0.2.0
Prefix Reserved
dotnet add package aweXpect.Snapshots --version 0.2.0
NuGet\Install-Package aweXpect.Snapshots -Version 0.2.0
<PackageReference Include="aweXpect.Snapshots" Version="0.2.0" />
<PackageVersion Include="aweXpect.Snapshots" Version="0.2.0" />
<PackageReference Include="aweXpect.Snapshots" />
paket add aweXpect.Snapshots --version 0.2.0
#r "nuget: aweXpect.Snapshots, 0.2.0"
#:package aweXpect.Snapshots@0.2.0
#addin nuget:?package=aweXpect.Snapshots&version=0.2.0
#tool nuget:?package=aweXpect.Snapshots&version=0.2.0
aweXpect.Snapshots
Snapshot testing for aweXpect.
At a glance
// compare a string with the snapshot that is stored next to the test
await Expect.That(description).MatchesSnapshot();
// compare an object, written completely and indented by the aweXpect formatter
await Expect.That(album).MatchesSnapshot();
// replace values that change from run to run before comparing
await Expect.That(playlist).MatchesSnapshot().For.Text(@"plays=\d+").AsRegex().Mask("plays=<count>");
// replace every Guid and ISO 8601 date with a numbered placeholder ({Guid_1}, {Date_1}, …)
await Expect.That(playlist).MatchesSnapshot().For.Guids().Mask().For.Dates().Mask();
// leave out, mask or convert members of an object, selected by their name, type or declaring type
await Expect.That(album).MatchesSnapshot()
.For.Members().WithName("PlayCount").Ignore()
.For.Members().WithName("Id").Mask()
.For.Members().DeclaredIn<Album>().WithName("Released").OfType<DateTime>().Convert(released => released.Year);
// store a JSON string as AlbumTests.Describes.awexpect-snapshot.json, so that editors and diff tools highlight it
await Expect.That(json).MatchesSnapshot().WithExtension("json");
// keep a snapshot per target framework and operating system (AlbumTests.Describes@net8.0@windows.awexpect-snapshot.txt)
await Expect.That(exception.Message).MatchesSnapshot().UniqueFor.TargetFramework().UniqueFor.OperatingSystem();
The snapshot is stored as <Class>.<Method>.awexpect-snapshot.txt next to the test file, where <Class> is the name
of the test file. A missing or different snapshot fails the test and writes the actual value to
<Class>.<Method>.awexpect-snapshot.pending.txt; rename it to <Class>.<Method>.awexpect-snapshot.txt to accept it,
or set the environment variable AWEXPECT_ACCEPT_SNAPSHOTS to all to accept all changed snapshots of a test run (or
to new to only add the missing ones). Snapshots of version 0.1 are named .snapshot. instead, see
Migrating from 0.1.
OrphanedSnapshots.CheckAsync() in the teardown of the test run reports the snapshots that no test uses any more on a
build server, and deletes them while accepting all changes.
Comparers decide whether a value matches its snapshot instead of the built-in
comparison, e.g. an image comparer that tolerates small differences of single pixels.
Reporters are told about every missing, different or matching snapshot, e.g. to open a
diff tool.
Overview
| Expectation | Subject | Summary |
|---|---|---|
MatchesSnapshot |
string |
matches the snapshot stored next to the test |
MatchesSnapshot |
any T |
matches the snapshot of the object, written by aweXpect |
Documentation
The full documentation is available at docs.testably.org.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- aweXpect.Core (>= 3.4.0)
-
net10.0
- aweXpect.Core (>= 3.4.0)
-
net8.0
- aweXpect.Core (>= 3.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.