Snapshots
Snapshots compare the serialized current value to a stored value under your snapshot directory.
Basic Usage
ts
import { expect, test } from "as-test";
test("serializes payload", () => {
expect("hello").toMatchSnapshot("greeting");
});Commands
bash
ast test
ast test --create-snapshots
ast test --overwrite-snapshots
ast test --no-snapshotBehavior
- snapshots are stored under
snapshotDir, which defaults to./.as-test/snapshots --create-snapshotscreates missing entries only--overwrite-snapshotsupdates mismatched entries--no-snapshotdisables snapshot assertions for that run- snapshot files are readable
.snaptext files
When To Use Them
Snapshots work well for:
- structured output
- generated text
- serialized records
- mocked host output
- results that would be noisy to assert field-by-field
