Repository navigation
PPLT-6233: Export CYPRESS_PERCY_SERVER_ADDRESS and add snapshot.exactResponsiveWidth #2466
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
base: master
Are you sure you want to change the base?
Changes from all commits
6539aa2
1764052
0616ec5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,6 +102,27 @@ function assertNotCrossOrigin(req) { | |
| const SDK_LOG_LEVELS = new Set(['debug', 'info', 'warn', 'error']); | ||
|
|
||
| // Create a Percy CLI API server instance | ||
| const exactWidthNoticeLogged = new WeakSet(); | ||
|
|
||
| // SDKs that size responsive captures from the healthcheck's snapshot.exactResponsiveWidth | ||
| // produce exact viewport widths, which can shift some existing baselines once | ||
| function logExactResponsiveWidthNotice(percy, body) { | ||
| if (exactWidthNoticeLogged.has(percy)) return; | ||
|
|
||
| let snapshot = [].concat(body).find(s => Array.isArray(s?.domSnapshot) && s.domSnapshot.length > 1); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recognize supported DOM snapshot field names. If an SDK posts a multi-entry
|
||
| if (!snapshot) return; | ||
|
|
||
| let exact = snapshot.exactResponsiveWidth ?? snapshot.exact_responsive_width ?? | ||
| percy.config.snapshot.exactResponsiveWidth; | ||
| if (exact === false) return; | ||
|
Comment on lines
+112
to
+117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check every responsive snapshot in a batch. If the first multi-entry DOM snapshot sets
|
||
|
|
||
| exactWidthNoticeLogged.add(percy); | ||
| logger('core:server').info([ | ||
| 'Responsive snapshots now use exact viewport widths; Edge, Firefox and remote-Chrome', | ||
| 'baselines may shift once. Set snapshot.exactResponsiveWidth: false to keep the previous behaviour.' | ||
| ].join(' ')); | ||
| } | ||
|
|
||
| export function createPercyServer(percy, port) { | ||
| let pkg = getPackageJSON(import.meta.url); | ||
|
|
||
|
|
@@ -234,6 +255,7 @@ export function createPercyServer(percy, port) { | |
| .route('post', '/percy/snapshot', async (req, res) => { | ||
| let data; | ||
| const snapshotPromise = {}; | ||
| logExactResponsiveWidthNotice(percy, req.body); | ||
| const snapshot = percy.snapshot(req.body, snapshotPromise); | ||
| if (!req.url.searchParams.has('async')) await snapshot; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: percy/cli
Length of output: 3947
Script executed:
Repository: percy/cli
Length of output: 6453
Web query:
@percy/cypress 3.1.8 source CYPRESS_PERCY_SERVER_ADDRESS Cypress.expose Cypress.envResult:
Provide the Percy address through Cypress
expose, not onlyCYPRESS_*environment variables.exec.js:124sets a child-process environment variable. The Cypress migration contract for@percy/cypress3.1.8+ movesPERCY_*values fromenvtoexpose. Therefore, this export alone can leave the SDK without the custom Percy address on Cypress 16. Update the SDK or provide an expose-compatible configuration path, then add a Cypress 16 end-to-end test.cy.env()is not the correct synchronous replacement for this non-sensitive configuration.