Skip to content

Commit

Permalink
Sync implementation (#444)
Browse files Browse the repository at this point in the history
* initial commit

* updating test

* updating test

* test: added test for percyScreenshot. fix: change response.data -> response.body.data

* chore: lint fix

* removed package-lock.json

* revert package-lock.json change

* added version 2.0.4

---------

Co-authored-by: this-is-shivamsingh <[email protected]>
  • Loading branch information
prklm10 and this-is-shivamsingh authored Jan 31, 2024
1 parent 6f689b0 commit 9f2a4dd
Show file tree
Hide file tree
Showing 4 changed files with 3,286 additions and 1,564 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ module.exports = async function percySnapshot(driver, 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,
domSnapshot,
name,
url
});
return response?.body?.data;
} catch (error) {
// Handle errors
log.error(`Could not take DOM snapshot "${name}"`);
Expand All @@ -51,7 +52,7 @@ module.exports = async function percySnapshot(driver, name, options) {
};

module.exports.request = async function request(data) {
await utils.captureAutomateScreenshot(data);
return await utils.captureAutomateScreenshot(data);
}; // To mock in test case

const getElementIdFromElements = async function getElementIdFromElements(elements) {
Expand Down Expand Up @@ -98,7 +99,7 @@ module.exports.percyScreenshot = async function percyScreenshot(driver, name, op
}

// Post the driver details to the automate screenshot endpoint with snapshot options and other info
await module.exports.request({
const response = await module.exports.request({
environmentInfo: ENV_INFO,
clientInfo: CLIENT_INFO,
sessionId: await driverData.getSessionId(),
Expand All @@ -107,6 +108,7 @@ module.exports.percyScreenshot = async function percyScreenshot(driver, name, op
snapshotName: name,
options
});
return response?.body?.data;
} catch (error) {
// Handle errors
log.error(`Could not take Screenshot "${name}"`);
Expand Down
Loading

0 comments on commit 9f2a4dd

Please sign in to comment.