✨ Allow snapshotting a list of pages to utilize the base-url flag#382
Merged
✨ Allow snapshotting a list of pages to utilize the base-url flag#382
Conversation
Also allow a list of page URLs rather than requiring objects containing URLs
Robdel12
approved these changes
Jun 21, 2021
Contributor
Robdel12
left a comment
There was a problem hiding this comment.
Slick! And then we can ship the new snapshot docs 🏁
samarsault
pushed a commit
that referenced
this pull request
Mar 3, 2023
Bumps [cypress](https://github.com/cypress-io/cypress) from 7.7.0 to 8.0.0. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js) - [Commits](cypress-io/cypress@v7.7.0...v8.0.0) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or 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
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.
What is this?
This PR refactors and tweaks the
percy snapshotcommand to be a little more friendly.First, a page listing no longer needs to be a list of objects containing at least a
urlproperty. Now the file can contain just a list of URLs in the appropriate format:Second, the
--base-urlflag was made to work with page listings in addition to the existing static directory usage. Since usage differs between page listings and static directories however, some other small adjustments were necessary.For static directories, the base URL should be the base PATHNAME that the site would be hosted at. Most sites are hosted at the domain root (
/), however some sites might be hosted at other paths (e.g./blog). This requirement has been present since the@percy/agentsnapshot command and continues to remain a requirement.For page listings, the base URL should be the entire base URL including the protocol and hostname. For example, the above list of URLs can be simplified to remove the common base URL:
To prevent mixing up the
static.base-urlconfiguration option with the page listing flag, a couple other changes were also made. The flag is no longer auto-mapped to the configuration option via thepercyrcflag property. Instead, it is passed along to the.percyrc()method which now accepts an initial overrides argument.The
static.base-urlconfiguration option was no longer being checked for the leading forward slash (only the flag is checked by the command now). A pattern requirement was added to the schema, and custom errors messages were added to config validation to print a better error message than what is normally printed for pattern failures. We can also utilize this pattern to do other better config validations in the future such as for certain discovery options.The
--dry-runflag will now print a better list of snapshots, however the defaultnamein core is only created when calling the snapshot method. The default name was also added here so dry runs can properly print it. When adding the default name here, I discovered a small bug in the core implementation in whichuri.pathneeded to be replaced withuri.pathname.