From 0a805f1ad3d08aac18a2d59f67d2297d086298ce Mon Sep 17 00:00:00 2001 From: this-is-shivamsingh Date: Wed, 25 Oct 2023 01:11:48 +0530 Subject: [PATCH] add coverage --- .../test/providers/automateProvider.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/webdriver-utils/test/providers/automateProvider.test.js b/packages/webdriver-utils/test/providers/automateProvider.test.js index 6de569a9d..2919b4396 100644 --- a/packages/webdriver-utils/test/providers/automateProvider.test.js +++ b/packages/webdriver-utils/test/providers/automateProvider.test.js @@ -170,6 +170,13 @@ 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(); @@ -177,6 +184,14 @@ describe('AutomateProvider', () => { 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', () => {