Your first snapshot
using AwesomeAssertions;
using Nullean.Snapshots;
public class GreetingTests
{
[Test]
public void Greets() =>
Greeter.Greet("world").Should().MatchSnapshot();
}
There is no verified file yet, so the test fails and says where it put what it got:
Text snapshot is new: no verified file at tests/App.Tests/.snapshots/GreetingTests/Greets.verified.txt
Received: .artifacts/.snapshots/received/App.Tests/GreetingTests/Greets.received.txt
Accept: snap accept App.Tests/GreetingTests/Greets (or: dnx Nullean.Snapshots.Cli accept App.Tests/GreetingTests/Greets)
Read the received file, then accept it:
snap diff Greets
snap accept Greets
- what would change
- write it as verified, delete the received file
A key can be given in full, as any unique suffix (Greets, GreetingTests/Greets) or as a glob
(GreetingTests/*). Or walk through everything pending at once with snap review.
You can also accept while running tests, locally only:
SNAPSHOT_ACCEPT=1 dotnet test --project tests/App.Tests --treenode-filter "/App.Tests/App.Tests/GreetingTests/Greets"
tests/App.Tests/.snapshots/GreetingTests/Greets.verified.txt is now part of your tests. Review its diff like code:
when a later change alters the output, the test fails, the received file shows the new output, and accepting it is a
decision you make, with the change in front of you.
Name them, or the second call fails because both would use the same file:
html.Should().MatchHtmlSnapshot(name: "header");
json.Should().MatchJsonSnapshot(name: "payload");