-
Notifications
You must be signed in to change notification settings - Fork 17
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
Property matcher support #37
Open
ethanresnick
wants to merge
26
commits into
suchipi:master
Choose a base branch
from
ethanresnick:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Very powerful for snapshotting deep structures
Before, we were doing all kinds of broken things: 1. Undercloning. I.e., we were mutating deep objects in the user’s data when a jsonpath matcher applied to them (because we only did a shallow clone). 2. Overcloning. If the user didn’t have property matchers, we still did an unecessary shallow clone on the data being snapshotted. This only happened if it was an object without custom serializers, so it was probably harmless, but still uneccessary. 3. We skipped all property matchers when a custom serializer was in use, when we really only needed to log a warning.
Has breaking API changes
Update to newest Jest Snapshot
Prettier config, standardized import-sort, dependency updates
This PR works great and would be super cool to merge! /cc @suchipi 🙏 |
Can we get this merged? Also the same for update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I understand that this code probably isn't ready to merge yet (e.g., it doesn't have tests or docs), but I wanted to at least open this PR in case others find it helpful.
Basically, it enables Jest 23 with property matchers, which make snapshot testing much more broadly applicable. The property matchers always go as the first argument (including when you're updating a snapshot with
to.matchSnaphot(matchers, true)
), and their values must come from theexpect
module that jest uses under the hood. I.e.,