Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add wdio support for ts #202

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
prklm10 marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something looks incorrect here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Amit3200 a similar fix for the issue can be seen in: percy/percy-selenium-js#406

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!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
Loading