Skip to content

Conversation

@MatthewMckee4
Copy link
Member

Summary

  • Add assert_json_snapshot function that serializes values via json.dumps(value, sort_keys=True, indent=2) for deterministic, readable snapshot output of dicts and lists
  • Extract shared assert_snapshot_impl helper from assert_snapshot to avoid duplicating snapshot comparison/write logic between the two functions
  • Supports all existing snapshot features: inline snapshots, named snapshots, --snapshot-update, filters via snapshot_settings, and the pending/accept workflow
  • Add type stubs, Python exports, and documentation

Test plan

  • 6 new integration tests: basic JSON, nested data, update mode, inline, filters, non-serializable value
  • All 580 existing tests pass (just test)
  • prek run -a passes (clippy, fmt, ruff, etc.)

@MatthewMckee4 MatthewMckee4 added the snapshot-testing Related to snapshot testing label Feb 10, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 10, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing add-assert-json-snapshot (786e461) with main (9d43f84)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 1 untouched benchmark

@MatthewMckee4 MatthewMckee4 force-pushed the add-assert-json-snapshot branch from 80fb9a9 to 6483234 Compare February 10, 2026 15:18
Extract shared `assert_snapshot_impl` helper to avoid duplicating
snapshot comparison/write logic, then add `assert_json_snapshot` which
serializes values via `json.dumps(value, sort_keys=True, indent=2)`
for deterministic, readable output of dicts and lists.

Supports all existing features: inline snapshots, named snapshots,
`--snapshot-update`, filters via `snapshot_settings`, and the
pending/accept workflow.
@MatthewMckee4 MatthewMckee4 force-pushed the add-assert-json-snapshot branch from 6483234 to 786e461 Compare February 10, 2026 15:25
@MatthewMckee4 MatthewMckee4 merged commit 153b7b7 into main Feb 10, 2026
8 checks passed
@MatthewMckee4 MatthewMckee4 deleted the add-assert-json-snapshot branch February 10, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot-testing Related to snapshot testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant