Skip to content

Commit

Permalink
Throwing error in case of healthcheck failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit3200 committed Dec 3, 2024
1 parent 1a9f77d commit 4c6c767
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async function currentURL(driver, options) {
const percySnapshot = async function percySnapshot(driver, name, options) {
if (!driver) throw new Error('An instance of the selenium driver object is required.');
if (!name) throw new Error('The `name` argument is required.');
if (!(await module.exports.isPercyEnabled())) return;
if (!(await module.exports.isPercyEnabled())) throw new Error('Percy is not running, disabling snapshots.');
if (utils.percy?.type === 'automate') {
throw new Error('Invalid function call - percySnapshot(). Please use percyScreenshot() function while using Percy with Automate. For more information on usage of percyScreenshot, refer https://www.browserstack.com/docs/percy/integrate/functional-and-visual');
}
Expand Down Expand Up @@ -187,7 +187,7 @@ module.exports.percyScreenshot = async function percyScreenshot(driver, name, op

if (!driver) throw new Error('An instance of the selenium driver object is required.');
if (!name) throw new Error('The `name` argument is required.');
if (!(await module.exports.isPercyEnabled())) return;
if (!(await module.exports.isPercyEnabled())) throw new Error('Percy is not running, disabling snapshots.');
if (utils.percy?.type !== 'automate') {
throw new Error('Invalid function call - percyScreenshot(). Please use percySnapshot() function for taking screenshot. percyScreenshot() should be used only while using Percy with Automate. For more information on usage of PercySnapshot(), refer doc for your language https://www.browserstack.com/docs/percy/integrate/overview');
}
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('percySnapshot', () => {
await helpers.test('error', '/percy/healthcheck');
let error = null;
try {
await percyScreenshot(driver, 'Snapshot 1');
await percySnapshot(driver, 'Snapshot 1');
} catch (e) {
error = e;
}
Expand Down

0 comments on commit 4c6c767

Please sign in to comment.