Skip to content

Commit

Permalink
refactor(tests): prefer inline-snapshot for most snapshots (#887)
Browse files Browse the repository at this point in the history
We now will use
[inline-snapshot](https://github.com/15r10nk/inline-snapshot) for the
majority of the snapshot tests as I find inline snapshots to be
considerably better as you don't lose context by having to switch to a
separate file to see the expected value.

We still use syrupy for the generation snapshot tests and any snapshot
tests used in `databases/` as they're shared between the sync and the
async tests, once both the sync client and async client can be imported
at once, the tests can be unified and we can rely on `inline-snapshot`.
  • Loading branch information
RobertCraigie authored Jan 29, 2024
1 parent 6485828 commit 1d73328
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 390 deletions.
8 changes: 7 additions & 1 deletion docs/contributing/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,13 @@ For a more specififc test case look through the tests and find one that is simil

### Snapshot Tests

We use [syrupy](https://github.com/tophat/syrupy) to manage our test snapshots. You can update the generated snapshots by running tests with `--snapshot-update`, for example:
We use [inline-snapshot](https://github.com/15r10nk/inline-snapshot) for, you guessed it, inline snapshots! If you're working with these snapshots you'll likely want to run tests with `--inline-snapshot=create` or `--inline-snapshot=fix`, for example:

```
nox -s test -p 3.9 -- --inline-snapshot=fix
```

We also use [syrupy](https://github.com/tophat/syrupy) to manage test snapshots that would be better to persist to standalone files. You can update the generated snapshots by running tests with `--snapshot-update`, for example:

```
nox -s test -p 3.9 -- --snapshot-update tests/test_generation/exhaustive
Expand Down
1 change: 1 addition & 0 deletions pipelines/requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
pytest-sugar
mock==5.1.0
pytest-subprocess==1.5.0
inline-snapshot==0.6.1
202 changes: 0 additions & 202 deletions tests/__snapshots__/test_builder.ambr

This file was deleted.

46 changes: 0 additions & 46 deletions tests/__snapshots__/test_validator.ambr

This file was deleted.

Loading

0 comments on commit 1d73328

Please sign in to comment.