Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ module.exports = function percySnapshot(name, options) {
await nEval(new Function(await utils.fetchPercyDOM()));

// Serialize and capture the DOM
const mergedOptions = utils.mergeSnapshotOptions(options);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] mergeSnapshotOptions requires a newer @percy/sdk-utils than the pinned range

utils.mergeSnapshotOptions was only added to @percy/sdk-utils in 1.32.0-beta.9, but package.json pins @percy/sdk-utils: ^1.0.0. An environment resolving an older 1.x sdk-utils satisfies the range yet lacks this export, so this line throws TypeError: utils.mergeSnapshotOptions is not a function and the snapshot is silently swallowed by the surrounding catch.

Suggestion: Bump the minimum @percy/sdk-utils to the version that ships mergeSnapshotOptions (e.g. ^1.32.0), or guard the call: const mergedOptions = utils.mergeSnapshotOptions?.(options) ?? options;

Reviewer: stack:code-review

/* istanbul ignore next: no instrumenting injected code */
let { domSnapshot, url } = await nEval(options => ({
/* eslint-disable-next-line no-undef */
domSnapshot: PercyDOM.serialize(options),
url: document.URL
}), options);
}), mergedOptions);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test coverage for this? is it covered in the existing UTs?


// Post the DOM to the snapshot endpoint with snapshot options and other info
await utils.postSnapshot({
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@
"test:types": "tsd"
},
"dependencies": {
"@percy/sdk-utils": "^1.0.0"
"@percy/sdk-utils": "^1.32.0"
},
"resolutions": {
"node-releases": "2.0.19",
"snyk-nodejs-lockfile-parser": "1.59.0"
},
"peerDependencies": {
"nightmare": "~3"
},
"devDependencies": {
"@percy/core": "^1.0.0",
"@percy/core": "^1.32.0",
"@types/nightmare": "^2.10.4",
"cross-env": "^7.0.2",
"eslint": "^7.11.0",
Expand Down
Loading
Loading