You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ai-usage.md
+94-2Lines changed: 94 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,10 +9,102 @@ To change this file edit the source file and then run MarkdownSnippets.
9
9
10
10
AI coding assistants (Claude Code, GitHub Copilot, Cursor, etc.) work well with Verify snapshot tests, but benefit from some project-level guidance. This page covers how to configure a project so AI assistants understand Verify's workflow.
11
11
12
+
There are two approaches: a **skill** (action-oriented, invocable on-demand) and a **context file** (passive, always-on knowledge). Both can be used together.
12
13
13
-
## AI context file
14
14
15
-
Add the following to the AI context file for the relevant tool. Adapt the test command and framework references to match the project.
15
+
## Skill
16
+
17
+
A skill provides action-oriented instructions that an AI assistant can invoke when handling Verify snapshot test failures.
18
+
19
+
Create a `SKILL.md` file in the appropriate directory for the tool:
description: Handle Verify snapshot test failures. Use this when a Verify snapshot test fails, when asked to accept or update snapshots, or when asked to add a new Verify test.
30
+
---
31
+
32
+
Handle [Verify](https://github.com/VerifyTests/Verify) snapshot test failures.
33
+
34
+
## Key concepts
35
+
36
+
-**`.verified.*` files** are the approved snapshots. They are committed to source control.
37
+
-**`.received.*` files** are the actual output from the latest test run. They are generated when a test fails (actual != expected) and are git-ignored.
38
+
39
+
## Handling a test failure
40
+
41
+
When a Verify snapshot test fails, follow this process:
42
+
43
+
### Step 1: Read the exception message
44
+
45
+
The exception message is machine-parsable:
46
+
47
+
```
48
+
Directory: /path/to/test/project
49
+
New:
50
+
- Received: TestClass.Method.received.txt
51
+
Verified: TestClass.Method.verified.txt
52
+
NotEqual:
53
+
- Received: TestClass.Method.received.txt
54
+
Verified: TestClass.Method.verified.txt
55
+
56
+
FileContent:
57
+
58
+
Received: TestClass.Method.received.txt
59
+
<receivedcontent>
60
+
Verified: TestClass.Method.verified.txt
61
+
<verifiedcontent>
62
+
```
63
+
64
+
-`Directory:` gives the base path for all file references.
65
+
-`New` means no `.verified.` file exists yet (first run or new test).
66
+
-`NotEqual` means the `.received.` and `.verified.` files differ.
67
+
-`Delete` means a `.verified.` file is no longer produced by any test.
68
+
-`FileContent:` contains the actual content for comparison.
69
+
70
+
### Step 2: Read the files
71
+
72
+
1. Read the `.received.*` file to see the actual output.
73
+
2. Read the `.verified.*` file (if it exists) to see the expected output.
74
+
3. Compare the two to understand the difference.
75
+
76
+
### Step 3: Determine the action
77
+
78
+
-**If the change is expected** (due to an intentional code change): copy the `.received.*` file over the `.verified.*` file to accept the new snapshot.
79
+
-**If it is a new test** (no `.verified.*` file): accept the `.received.*` file as the new snapshot by renaming it to `.verified.*`.
80
+
-**If the change is a bug**: fix the code, not the snapshot. Re-run the test to confirm the fix.
81
+
82
+
## Rules
83
+
84
+
-**Never hand-edit `.verified.*` files** to make tests pass. Always let Verify generate the correct output by running the test.
85
+
- Snapshot files live next to the test source file. For a test in `Tests/MyTests.cs`, look for `Tests/MyTests.MethodName.verified.txt`.
86
+
87
+
## Scrubbed values
88
+
89
+
Verify replaces non-deterministic values with stable placeholders. These are intentional:
90
+
91
+
- GUIDs become `Guid_1`, `Guid_2`, etc.
92
+
- DateTimes become `DateTime_1`, `DateTime_2`, etc.
93
+
- File paths become `{SolutionDirectory}`, `{ProjectDirectory}`, `{TempPath}`.
94
+
95
+
Do not treat these placeholders as errors.
96
+
97
+
## Verified file conventions
98
+
99
+
- Encoding: UTF-8 with BOM
100
+
- Line endings: LF (not CRLF)
101
+
- No trailing newline
102
+
~~~
103
+
104
+
105
+
## Context file
106
+
107
+
A context file provides passive, always-on knowledge about Verify. Add the following to the AI context file for the relevant tool. Adapt the test command and framework references to match the project.
Copy file name to clipboardExpand all lines: docs/mdsource/ai-usage.source.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ name: verify-snapshot-testing
22
22
description: Handle Verify snapshot test failures. Use this when a Verify snapshot test fails, when asked to accept or update snapshots, or when asked to add a new Verify test.
23
23
---
24
24
25
-
You are a specialized agent for handling[Verify](https://github.com/VerifyTests/Verify) snapshot test failures.
25
+
Handle[Verify](https://github.com/VerifyTests/Verify) snapshot test failures.
Copy file name to clipboardExpand all lines: docs/mdsource/text-file-settings.include.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ All text extensions of `*.verified.*` should have:
14
14
*`eol` set to `lf`
15
15
*`working-tree-encoding` set to `UTF-8`
16
16
17
-
Note: `working-tree-encoding=UTF-8` is correct even though Verify writes files with a BOM. Git doesn't strip or add the BOM — it just passes through transparently. The `UTF-8-BOM` encoding would explicitly add a BOM on checkout and strip it on commit (so the internal blob differs from the working tree), but that's not the desired behavior since Verify writes the BOM itself and it should be preserved in the blob too.
17
+
Note: `working-tree-encoding=UTF-8` is correct even though Verify writes files with a BOM. Git does not strip or add the BOM — it passes through transparently. The `UTF-8-BOM` encoding would explicitly add a BOM on checkout and strip it on commit (so the internal blob differs from the working tree), but that is not the desired behavior since Verify writes the BOM itself and it should be preserved in the blob.
18
18
19
19
All Binary files should also be marked to avoid merging and line ending issues with binary files.
Copy file name to clipboardExpand all lines: docs/wiz/Linux_Other_Cli_Expecto_AppVeyor.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,8 @@ All text extensions of `*.verified.*` should have:
69
69
*`eol` set to `lf`
70
70
*`working-tree-encoding` set to `UTF-8`
71
71
72
+
Note: `working-tree-encoding=UTF-8` is correct even though Verify writes files with a BOM. Git does not strip or add the BOM — it passes through transparently. The `UTF-8-BOM` encoding would explicitly add a BOM on checkout and strip it on commit (so the internal blob differs from the working tree), but that is not the desired behavior since Verify writes the BOM itself and it should be preserved in the blob.
73
+
72
74
All Binary files should also be marked to avoid merging and line ending issues with binary files.
Copy file name to clipboardExpand all lines: docs/wiz/Linux_Other_Cli_Expecto_AzureDevOps.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,8 @@ All text extensions of `*.verified.*` should have:
69
69
*`eol` set to `lf`
70
70
*`working-tree-encoding` set to `UTF-8`
71
71
72
+
Note: `working-tree-encoding=UTF-8` is correct even though Verify writes files with a BOM. Git does not strip or add the BOM — it passes through transparently. The `UTF-8-BOM` encoding would explicitly add a BOM on checkout and strip it on commit (so the internal blob differs from the working tree), but that is not the desired behavior since Verify writes the BOM itself and it should be preserved in the blob.
73
+
72
74
All Binary files should also be marked to avoid merging and line ending issues with binary files.
Copy file name to clipboardExpand all lines: docs/wiz/Linux_Other_Cli_Expecto_GitHubActions.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,8 @@ All text extensions of `*.verified.*` should have:
69
69
*`eol` set to `lf`
70
70
*`working-tree-encoding` set to `UTF-8`
71
71
72
+
Note: `working-tree-encoding=UTF-8` is correct even though Verify writes files with a BOM. Git does not strip or add the BOM — it passes through transparently. The `UTF-8-BOM` encoding would explicitly add a BOM on checkout and strip it on commit (so the internal blob differs from the working tree), but that is not the desired behavior since Verify writes the BOM itself and it should be preserved in the blob.
73
+
72
74
All Binary files should also be marked to avoid merging and line ending issues with binary files.
Copy file name to clipboardExpand all lines: docs/wiz/Linux_Other_Cli_Expecto_None.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,8 @@ All text extensions of `*.verified.*` should have:
69
69
*`eol` set to `lf`
70
70
*`working-tree-encoding` set to `UTF-8`
71
71
72
+
Note: `working-tree-encoding=UTF-8` is correct even though Verify writes files with a BOM. Git does not strip or add the BOM — it passes through transparently. The `UTF-8-BOM` encoding would explicitly add a BOM on checkout and strip it on commit (so the internal blob differs from the working tree), but that is not the desired behavior since Verify writes the BOM itself and it should be preserved in the blob.
73
+
72
74
All Binary files should also be marked to avoid merging and line ending issues with binary files.
Copy file name to clipboardExpand all lines: docs/wiz/Linux_Other_Cli_Fixie_AppVeyor.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,8 @@ All text extensions of `*.verified.*` should have:
68
68
*`eol` set to `lf`
69
69
*`working-tree-encoding` set to `UTF-8`
70
70
71
+
Note: `working-tree-encoding=UTF-8` is correct even though Verify writes files with a BOM. Git does not strip or add the BOM — it passes through transparently. The `UTF-8-BOM` encoding would explicitly add a BOM on checkout and strip it on commit (so the internal blob differs from the working tree), but that is not the desired behavior since Verify writes the BOM itself and it should be preserved in the blob.
72
+
71
73
All Binary files should also be marked to avoid merging and line ending issues with binary files.
0 commit comments