Skip to content

Commit

Permalink
add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
this-is-shivamsingh committed Oct 24, 2023
1 parent a9cbe39 commit 0a805f1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/webdriver-utils/test/providers/automateProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,28 @@ describe('AutomateProvider', () => {
await expectAsync(automateProvider.percyScreenshotBegin('abc')).toBeRejectedWithError('OS/Browser/Selenium combination is not supported');
});

it('throw "Got invalid error resposne" if result.value does not exists', async () => {
const automateProvider = new AutomateProvider('1234', 'https://localhost/command-executor', { platform: 'win' }, {}, {}, 'client', 'environment', {}, percyBuildInfo);
await automateProvider.createDriver();
automateProvider.driver.executeScript = jasmine.createSpy().and.returnValue(Promise.resolve({ status: 13 }));
await expectAsync(automateProvider.percyScreenshotBegin('abc')).toBeRejectedWithError('Got invalid error response');
});

it('mark percy sesssion as failure', async () => {
const automateProvider = new AutomateProvider('1234', 'https://localhost/command-executor', { platform: 'win' }, {}, {}, 'client', 'environment', {}, percyBuildInfo);
await automateProvider.createDriver();
// eslint-disable-next-line prefer-promise-reject-errors
automateProvider.driver.executeScript = jasmine.createSpy().and.returnValue(Promise.reject({ response: { body: JSON.stringify({ value: { error: 'OS/Browser/Selenium combination is not supported', message: 'OS/Browser/Selenium combination is not supported' } }) } }));
await expectAsync(automateProvider.percyScreenshotBegin('abc')).toBeRejectedWithError('OS/Browser/Selenium combination is not supported');
});

it('catch direct response error', async () => {
const automateProvider = new AutomateProvider('1234', 'https://localhost/command-executor', { platform: 'win' }, {}, {}, 'client', 'environment', {}, percyBuildInfo);
await automateProvider.createDriver();
// eslint-disable-next-line prefer-promise-reject-errors
automateProvider.driver.executeScript = jasmine.createSpy().and.returnValue(Promise.reject('Random Error'));
await expectAsync(automateProvider.percyScreenshotBegin('abc')).toBeRejectedWithError('Random Error');
});
});

describe('percyScreenshotEnd', () => {
Expand Down

0 comments on commit 0a805f1

Please sign in to comment.