Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧪 Add snapshot testing for needs data #1019

Merged
merged 4 commits into from
Sep 12, 2023
Merged

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Sep 11, 2023

Previously, the validity of needs data was tested by asserting for only specific keys and values.
This PR adds snapshot testing, with https://github.com/tophat/syrupy, to more fully capture the generated data.
This should help to better identify any regressions caused by future changes (such as in #1018).

Previously, the validity of needs data was tested by asserting for only specific keys and values.
This PR adds snapshot testing, with https://github.com/tophat/syrupy, to more fully capture the generated data.
This should help to better identify any regressions caused by future changes (such as #1018).
Copy link
Member

@danwos danwos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great idea, using snapshot for this.

Is the snapshot-file taken automatically based on the test-file name?
Can the exact name of the snapshot be configured in the pytest?
I see use cases, where the snapshot may differ for specific tests in the same test-file.
Maybe this can also be documented in contributing in 1-2 lines.

However, approved 👍

@chrisjsewell
Copy link
Member Author

Is the snapshot-file taken automatically based on the test-file name?

Yes

Can the exact name of the snapshot be configured in the pytest?

I don't believe so

I see use cases, where the snapshot may differ for specific tests in the same test-file.

I think maybe you are misunderstanding?
A snapshot file can hold multiple snapshots, for a single test file; for each test and even multiple per test (https://github.com/tophat/syrupy#name)

@chrisjsewell chrisjsewell merged commit 09277e3 into master Sep 12, 2023
@chrisjsewell chrisjsewell deleted the snapshot-testing branch September 12, 2023 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants