Skip to content

Commit 833518c

Browse files
authored
docs: explain snapshot update process (#1040)
1 parent d9c6f40 commit 833518c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,28 @@ $ npx prism mock path/to/your/openapi.yml
9696
$ ./scripts/test
9797
```
9898

99+
### Snapshots
100+
101+
Some tests use [inline-snapshot](https://15r10nk.github.io/inline-snapshot/latest/). To update them after making changes, rerun the tests with the `--inline-snapshot=fix` and `-n0` options:
102+
103+
```bash
104+
./scripts/test --inline-snapshot=fix -n0
105+
```
106+
107+
> [!NOTE]
108+
> `inline-snapshot` is incompatible with [pytest-xdist](https://github.com/pytest-dev/pytest-xdist), so you need to disable parallel execution `(-n0)` when using the `--inline-snapshot` option.
109+
110+
In addition, some tests capture snapshots of the HTTP requests they make.
111+
To refresh these snapshots, run the tests with the `ANTHROPIC_LIVE=1` environment variable enabled.
112+
113+
```bash
114+
ANTHROPIC_LIVE=1 ./scripts/test --inline-snapshot=fix
115+
```
116+
117+
> [!NOTE]
118+
> Sometimes it makes sense to update only the inline snapshots `(--inline-snapshot=fix)` without refreshing the HTTP snapshots `(ANTHROPIC_LIVE=1)`.
119+
> This is useful when the endpoint hasn’t changed, but your code handles the response differently and the assertions need updating.
120+
99121
## Linting and formatting
100122

101123
This repository uses [ruff](https://github.com/astral-sh/ruff) and

tests/lib/tools/test_runners.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#
2626
# you can update them with
2727
#
28-
# `ANTHROPIC_LIVE=1 pytest --inline-snapshot=fix -p no:xdist -o addopts=""`
28+
# `ANTHROPIC_LIVE=1 ./scripts/test --inline-snapshot=fix -n0`
2929

3030
snapshots = {
3131
"basic": {

0 commit comments

Comments
 (0)