Skip to content
Playground(another site)

bynk.test.snapshot_in_property

Error A property takes a snapshot; its body runs once per generated input, so the snapshot belongs in a case over a fixed value.

A snapshot is keyed by its case and name, so it holds one value. A property runs its body once for each generated input, so there is no single value to store. Snapshot a fixed value in a case, and let the property assert what holds for every input.

Example

tests/api.test.bynk
property "every n" {
for all n: Int {
expect run(n) matches snapshot "n" // ✗ many inputs, one snapshot
}
}
case "one n" {
expect run(3) matches snapshot "n" // ✓
}

In the Book

See also

  • The grammar rule it governs: snapshot_expr.
  • Every code in its category, Tests, on the diagnostic index.
  • bynk explain bynk.test.snapshot_in_property shows the same from the installed toolchain, without a network.