snapshot-testing

Implements snapshot testing in .NET applications using the Verify library.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill snapshot-testing-agibuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: snapshot-testing
Source: https://github.com/AGIBuild/dotnet.CI.template/tree/main/.cursor/skills/snapshot-testing
Command: npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill snapshot-testing-agibuild

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Detecting unintended changes in rendered output, serialized objects, HTTP responses, and public API surfaces is tedious with manual assertions. This Skill provides patterns for snapshot testing with Verify, where output is compared against human-approved baselines and any change requires explicit review. ## Core Features & Use Cases - Snapshot Verification: Verify objects, strings, streams, HTML emails, and HTTP responses against approved .verified. baseline files. - Scrubbing Non-Deterministic Values: Automatically replace dates, GUIDs, tokens, and machine names with stable placeholders so tests stay deterministic. - API Surface Approval: Capture the full public API of an assembly so breaking changes require explicit approval. - Use Case: When rendering an order confirmation email, snapshot the HTML output so any CSS or template regression fails the test and shows a diff for review. ## Quick Start Add snapshot tests to my .NET test project using Verify to verify the rendered output of my email templates and scrub non-deterministic values.

Frequently Asked Questions about snapshot-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write snapshot tests in .NET with Verify?▼

Install the Verify.Xunit package, add a module initializer, mark the test class with [UsesVerify], and call Verify(target) inside a test returning Task. The first run creates a .received. file that you approve into a .verified. baseline.

How to handle dates and GUIDs in snapshot tests?▼

Scrub non-deterministic values so snapshots stay stable across runs. Use VerifierSettings.ScrubMembersWithType<DateTime>() and ScrubMembersWithType<Guid>() globally, or chain ScrubLinesWithReplace and IgnoreMember on individual Verify calls.

Can Verify test HTTP responses in ASP.NET Core?▼

Yes, the Verify.Http package supports verifying full HttpResponseMessage objects including headers and body. Combine it with WebApplicationFactory in integration tests, or deserialize the response body and verify the DTO while ignoring volatile members.

Why do snapshot tests fail in CI but pass locally?▼

Failures usually come from unscrubbed environment-specific values like machine names or paths, or from line-ending differences. Configure .gitattributes for verified files and set DiffEngine_Disabled or the CI environment variable so tests fail cleanly instead of launching a diff tool.

When should I not use snapshot testing?▼

Avoid snapshot testing for simple value checks where Assert.Equal is clearer, for business logic needing explicit assertions, and for rapidly evolving APIs where baselines change constantly. It works best for complex outputs like rendered HTML and serialization formats.