Calque — a lightweight snapshot testing and review tool for Elixir projects.
Calque allows you to:
- Record test outputs as snapshot files (
*.snap) - Compare new outputs against previously accepted snapshots
- Review and accept/reject snapshots interactively from the CLI
Typical usage
Calque.check(result, "my test title")If no accepted snapshot exists, Calque will create one and fail the test, prompting you to review it with:
mix calque reviewCalque stores all snapshots under calque_snapshots/ in your project root.
CLI commands
mix calque review— review new or changed snapshots interactivelymix calque accept-all— accept all pending snapshotsmix calque reject-all— reject all pending snapshotsmix calque clean— delete pending, rejected, and unreferenced snapshotsmix calque help— show CLI usage information
Summary
Functions
Performs a snapshot test using the calling function name as the snapshot title.
Performs a snapshot test with an explicit snapshot title.
Types
@type cli_command() :: :review | :accept_all | :reject_all | :clean | :help
@type snapshot() :: Calque.Snapshot.t()
Functions
Performs a snapshot test using the calling function name as the snapshot title.
This macro is a convenience wrapper around check/2. The snapshot title is
automatically inferred from the surrounding function or test name, making it
the preferred API in most cases.
It behaves exactly like check/2: the content is compared against the accepted
snapshot, and the test fails if a new snapshot is created or a difference is
detected.
Examples
Inside an ExUnit test:
test "renders empty state" do
html = render_empty_state()
Calque.check(html)
endThe snapshot title will automatically be set to:
"renders empty state"This keeps snapshot names stable and closely aligned with test intent, without requiring any manual naming.
Performs a snapshot test with an explicit snapshot title.
This function writes the given content to a snapshot file (if none exists) and compares it against the previously accepted snapshot.
In practice, you will usually prefer check/1, which automatically derives
the snapshot title from the calling test. Use check/2 when you need full
control over the snapshot name.
Examples
Using an explicit snapshot title:
test "renders order confirmation" do
html = render_confirmation(order)
Calque.check(html, "order_confirmation")
endIf the snapshot matches the accepted version, the test passes silently:
:okIf no snapshot exists yet, or if the content differs, the test fails and prints a helpful diff.