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.
Compare pages API
📖 📖 docs only 📖 📖 , implementation to follow
Background
Work done
I have a proof of concept working on my local machine, so now I'm thinking about a good API.
Attempt 1 (commit)
Uses config objects and introduces an internal cache object to keep store image data for later comparisons. This roughly matches the different parameter usage that
toMatchSnapshot
has when chained vs unchained.Attempt 2 (current state)
I then decided against adding internal state. If that is done for every new feature, the lib might not scale so well? I though perhaps better to expose (the edges of) the internals, and give people the power.
So, I propose:
introspect
". It takes a function which it calls with a proxy (lowercase "p") object with certain exposed state - aka a big bag of variables.compareImages
function, with a config objectAlternative
If you don't like these two, initially I was passing in the spec, and using that to access the appropriate snapshot to compare against.
Notes
Due to the async control-flow of the chained API, the cached image that is passed to
.compareImages
needs to be accessed dynamically.