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.
What is this?
This PR adds support for snapshots that may have differing DOM for different widths. In order to take advantage of this new feature, snapshot uploads must be deferred using the new
defer-uploads
config option. This is because all snapshot resources, including multiple root resources, must be discovered before the snapshot is sent to our infrastructure to be rendered for screenshots.Changes
To facilitate multiple root resources, each root resource is identified by their associated widths using a new
for-widths
attribute for snapshot resources. When uploads are deferred, new snapshots of the same name will be merged with existing snapshots. While merging, previously discovered resources are discarded if they are no longer associated with any widths. This allows retries to work with multiple DOM snapshots when the same width snapshot is taken more than once.For the
percy snapshot
command, the resource capture function was adjusted to take multi DOM snapshots between resizes by keeping track of the last width before the resize took place. When additional snapshots are defined, the page is resized back to it's initial size before each additional snapshot is iterated over.For snapshots taken by SDKs using a
domSnapshot
option, they can now supply a singularwidth
option instead of an array consisting of a single width. This should allow custom snapshot functions to more easily supply the width when iterating over snapshot sizes.Examples
Required
.percy.yml
config:Puppeteer example:
Cypress example: