Snapshot Testing

Catch regressions with snapshot approval tests for APIs

LoopyLuci Updated 1 repo stars

File contents

Snapshot Testing

syrupy (Python)

pip install syrupy
def test_api_response(snapshot):
    resp = client.get("/api/users")
    assert resp.json() == snapshot

First Run

Creates snapshot file. Subsequent runs compare.

Update Snapshots

pytest --snapshot-update

Best For

  • API response shapes
  • Serialization output
  • Error message formatting

LoopyLuci/Skills/tree/main/skills/snapshot-testing commit 8cee750a1f

Frequently asked questions

npx skillmds@latest add loopyluci/snapshot-testing