A hands-on demo for inline-snapshot — the pytest plugin that writes your expected values for you.
Just run ./demo.sh and see the full workflow in action: create snapshots from live API calls, break them with a new feature, and fix them in one command. No slides, no reading — one script, real understanding.
A small Python CLI that fetches your location (via ip-api.com) and current weather (via Open-Meteo), then displays a report.
The interesting part is the tests: they hit the real APIs, and --inline-snapshot=create writes the expected values into the test file automatically.
An interactive demo walks you through the full workflow in three acts:
- Create — fill empty snapshots from live API responses
- Break — add a feature (
continent) that changes the data shape - Fix — update all snapshots in one command
Tip: Read the full step-by-step walkthrough in TUTORIAL.md.
- Python 3.11+
- UV — a fast Python package manager
- Internet connection (the tests call live APIs)
If you don't have UV yet, install it with a single command:
curl -LsSf https://astral.sh/uv/install.sh | shNote: On macOS you can also use
brew install uv. See the UV docs for other options.
Verify it works:
$ uv --version
uv 0.6.xgit clone https://github.com/miguelp/snapshottest.git
cd snapshottest
uv syncThat's it. uv sync creates the virtual environment and installs all dependencies.
./demo.shThe script is idempotent — run it as many times as you want. It resets everything on each run and restores files on exit.
It will:
- Write a test file with empty
snapshot()calls - Run
--inline-snapshot=createto fill them from live APIs - Apply the continent feature (breaks existing snapshots)
- Run
--inline-snapshot=create,fixto update everything in one pass
Info: The demo requires an internet connection. It calls ip-api.com and Open-Meteo — both free, no API key needed.
uv run python -m snapshottest.cli weatherOr as JSON:
uv run python -m snapshottest.cli weather --jsonuv run pytest tests/ -vTo fill empty snapshots:
uv run pytest tests/ -v --inline-snapshot=createTip: See all available flags in the inline-snapshot docs.
snapshottest/
├── src/snapshottest/
│ ├── models.py # Location, Weather, WeatherReport
│ ├── location.py # IP geolocation (ip-api.com)
│ ├── weather.py # Current weather (Open-Meteo)
│ └── cli.py # Typer CLI + Rich output
├── tests/
│ ├── conftest.py # Network guard (skip when offline)
│ ├── test_demo.py # Real-API tests with inline snapshots
│ └── test_weather_report.py # Error-path test
├── demo/
│ └── continent/ # Feature files used by demo.sh
├── demo.sh # Interactive 3-act demo
├── TUTORIAL.md # Full written tutorial
└── pyproject.toml
- TUTORIAL.md — step-by-step guide through the whole workflow
- inline-snapshot docs — the library this demo is built around
- UV docs — the package manager used here