# Visual regression tests

A visual test should tell you what changed, not merely that a string changed. Start from a known interaction state, capture it with fixed geometry and fonts, and inspect the difference when the test fails.

## Capture the same state every time

Use `TestSinglePageApp` for a complete application or `SVGDocument` for an isolated view. The [counter scenario](../deterministic/index.md) supplies a small application to start with. After asserting its label, a snapshot call can record that state:

```csharp
// Inside app.Run, after the behavior assertion:
app.Snapshot("After increment");
```

This is a fragment to add to that test, not a second standalone test. The harness stores scenario files beside the calling test source. On a first run it writes candidate expected SVG/report files and diagnostics, then fails for the missing baseline. Review those candidates before committing them. A second run can match the newly written files, so a passing rerun alone does not count as visual review.

Supply the same viewport and Inter font assets on every machine. For software drawing used directly, dispose the drawing context before reading its stream so the closing SVG content has been written.

## Review a failure

First check the behavior assertion. If navigation missed its destination, fix the scenario rather than approving a picture of the home page. Next compare the intended visual change: position, clipping, typography, color, or content.

Integration mismatches write `*.DIFF.svg` and `README.DIFF.md`; component tests may write `*.Actual.svg`. Keep those diagnostic files out of committed baselines. Promote only the reviewed expected output, then rerun the test to confirm it compares cleanly.

## Know what SVG proves

SVG captures vector drawing and software text measurement. It does not prove native blur, platform font rasterization, IME placement, or GPU depth behavior. A GPU view may deliberately render a fallback for capture; do not treat that fallback as evidence that the hardware path works.

Use a native screenshot or backend pixel test for those effects. Keep the distinction in the test name and report so a passing software test cannot be mistaken for cross-platform validation.
