Easily spot regressions in your tests.
A Pytest plugin for snapshot testing: a test returns a value, the plugin stores it in a snapshot file, and compares the next runs with it.
pip install pytest-resultsReturn the value to check from your test:
def test_function():
return {"hello": "world"}The first run fails, since there is no snapshot to compare with yet. Accept the new results to store them as snapshots:
pytest --accept-diffThe snapshots are stored as JSON files in the __pytest_results__ folder, at the root
of your project. Commit this folder: from now on, the test fails whenever its result
changes.
When a test fails, open the differences in your IDE with the --ide option:
pytest --ide vscodeThe supported IDEs are cursor, pycharm and vscode.
If the changes are expected, update the snapshots with pytest --accept-diff.
- Regression fixture: checking results, supported types, snapshot files and custom formats.
- Configuration: command line options and configuration file.