Skip to content

Commit

Permalink
Adding support for returning response for percy (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit3200 authored Apr 1, 2024
1 parent d660fa7 commit 7053241
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ async function percySnapshot(page, name, options) {
}, options);

// Post the DOM to the snapshot endpoint with snapshot options and other info
await utils.postSnapshot({
const response = await utils.postSnapshot({
...options,
environmentInfo: ENV_INFO,
clientInfo: CLIENT_INFO,
url: page.url(),
domSnapshot,
name
});
return response?.body?.data;
} catch (err) {
log.error(`Could not take DOM snapshot "${name}"`);
log.error(err);
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@
"publishConfig": {
"access": "public"
},
"dependencies": {
"@percy/sdk-utils": "^1.0.0"
},
"peerDependencies": {
"playwright-core": ">=1"
},
"devDependencies": {
"@percy/cli": "^1.10.4",
"@percy/cli": "^1.28.2",
"@playwright/test": "^1.24.2",
"cross-env": "^7.0.2",
"eslint": "^7.18.0",
Expand Down
4 changes: 3 additions & 1 deletion tests/index.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ test.describe('percySnapshot', () => {
test('posts snapshots to the local percy server', async ({ page }) => {
await percySnapshot(page, 'Snapshot 1');
await percySnapshot(page, 'Snapshot 2');
await percySnapshot(page, 'Snapshot 3', { sync: true });

expect(await helpers.get('logs')).toEqual(expect.arrayContaining([
'Snapshot found: Snapshot 1',
'Snapshot found: Snapshot 2',
`- url: ${helpers.testSnapshotURL}`,
expect.stringMatching(/clientInfo: @percy\/playwright\/.+/),
expect.stringMatching(/environmentInfo: playwright\/.+/)
expect.stringMatching(/environmentInfo: playwright\/.+/),
expect.stringMatching(/The Synchronous CLI functionality is not compatible with skipUploads option./)
]));
});

Expand Down

0 comments on commit 7053241

Please sign in to comment.