Skip to content

Commit

Permalink
add wdio support for ts
Browse files Browse the repository at this point in the history
  • Loading branch information
this-is-shivamsingh committed Nov 2, 2023
1 parent d23ba9d commit c851a04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions percy/driver/driverWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class AppiumDriver {
/* istanbul ignore else */
// Note: else is covered here but constructor name '' couldnt cover (which is the case)
// in real world when you get wd driver passed so need to ignore coverage on it
if (driver.constructor.name === 'Browser' && !Undefined(driver.getSession)) {
if (driver.constructor.name.includes('Browser') && !Undefined(driver.getSession)) {
this.type = 'wdio';
} else if ((driver.constructor.name === '' ||
driver.constructor.name === 'Object') && // Object check is only added for tests
driver.constructor.name.includes('Object')) && // Object check is only added for tests
!Undefined(driver.sessionCapabilities)) {
this.type = 'wd';
}
Expand Down
14 changes: 14 additions & 0 deletions test/percy/appium/driverWrapper.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import wdioDriver from '../../mocks/appium/wdio_driver.js';

describe('AppiumDriver', () => {
describe('getPercyOptions', () => {
class BoundBrowser { // Mocking ts WDIO driver
constructor() {
this.sessionId = '123';
this.capabilities = { browserName: 'chrome' };
this.options = { protocol: 'https', path: '/wd/hub', hostname: 'hub-cloud.browserstack.com' };
}
getSession() { return { platformDetails: { platformName: 'android' } } }
}

it('Should work with typescript wdio', async () => {
const driver = new AppiumDriver(new BoundBrowser());
expect(driver.sessionId).toEqual('123')
});

it('returns default options if no options are provided', async () => {
const driver = new AppiumDriver(wdDriver());

Expand Down

0 comments on commit c851a04

Please sign in to comment.