Add ability to update snapshots (#4)

This commit is contained in:
Patrick Stevens
2025-06-16 11:53:26 +01:00
committed by GitHub
parent 39370d5235
commit 9d20d18954
18 changed files with 727 additions and 34 deletions

View File

@@ -5,8 +5,9 @@ An [expect-testing](https://blog.janestreet.com/the-joy-of-expect-tests/) librar
# Current status
Basic mechanism works, but I haven't yet decided how the ergonomic updating of the input text will work.
Ideally it would edit the input AST, but I don't yet know if that's viable.
The basic mechanism works.
Snapshot updating is vibe-coded with Opus 4 and is purely text-based; I didn't want to use the F# compiler services because that's a pretty heavyweight dependency which should be confined to a separate test runner entity.
It's not very well tested, and I expect it to be kind of brittle.
# How to use
@@ -35,6 +36,10 @@ let ``This test fails: plain text comparison of ToString`` () =
}
```
# Limitations
* The snapshot updating mechanism *requires* you to use verbatim string literals. While the test assertions will work correctly if you do `snapshot ("foo" + "bar" + f 3)`, for example, the updating code is liable to do something undefined in that case. Also do not use format strings (`$"blah"`).
# Licence
MIT.