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

embed expect-webdriverio in framework adapters #5335

Merged
merged 7 commits into from Apr 28, 2020

Conversation

christian-bromann
Copy link
Member

Proposed changes

See issue #5326. We have to embed expect-webdriverio typings into the framework typings so that it will be available automatically.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

n/a

Reviewers: @webdriverio/project-committers

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Apr 28, 2020
@christian-bromann christian-bromann requested a review from a team April 28, 2020 11:22
Copy link
Member

@mgrybyk mgrybyk left a comment

Choose a reason for hiding this comment

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

LGTM

@christian-bromann
Copy link
Member Author

@mgrybyk seems like some issue with the typings:

../../../packages/wdio-cucumber-framework/node_modules/expect-webdriverio/types/jest-expect-clone/jest-expect.d.ts:76:15 - error TS2430: Interface 'Matchers<R, T>' incorrectly extends interface 'Matchers'.
  The types returned by 'toHaveProperty(...)' are incompatible between these types.
    Type 'R' is not assignable to type 'undefined'.

76     interface Matchers<R, T> {

@mgrybyk
Copy link
Member

mgrybyk commented Apr 28, 2020

Let me take a look

@mgrybyk
Copy link
Member

mgrybyk commented Apr 28, 2020

@christian-bromann this one webdriverio/expect-webdriverio@a4f7a7a broke everything.

Have to partially revert it and all the errors in the current PR will gone

@christian-bromann
Copy link
Member Author

broke everything.

Can you specify what broke? It seem to work just fine without the change from this PR.

@mgrybyk
Copy link
Member

mgrybyk commented Apr 28, 2020

@christian-bromann webdriverio/expect-webdriverio@a4f7a7a#diff-045247205377646525c5096c7eed6582L67-R67

We can't use undefined there, it should be either any or generic. I'll rise PR to expect-webdriverio in a moment.

My local project fails to compile with latest expect-webdriverio as well

@mgrybyk
Copy link
Member

mgrybyk commented Apr 28, 2020

Copy link
Member

@erwinheitzman erwinheitzman left a comment

Choose a reason for hiding this comment

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

Looking good!

Copy link
Member

@erwinheitzman erwinheitzman left a comment

Choose a reason for hiding this comment

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

Didn't see the comments before I approved

@christian-bromann
Copy link
Member Author

There are still some Jasmine errors which should be fixeable in this PR I assume:

../../../packages/wdio-jasmine-framework/node_modules/@types/jasmine/ts3.1/index.d.ts(112,18): error TS2451: Cannot redeclare block-scoped variable 'expect'.
../../../packages/wdio-jasmine-framework/node_modules/@types/jasmine/ts3.1/index.d.ts(119,18): error TS2451: Cannot redeclare block-scoped variable 'expect'.
../../../packages/wdio-jasmine-framework/node_modules/@types/jasmine/ts3.1/index.d.ts(126,18): error TS2451: Cannot redeclare block-scoped variable 'expect'.
../../../packages/wdio-jasmine-framework/node_modules/@types/jasmine/ts3.1/index.d.ts(131,18): error TS2451: Cannot redeclare block-scoped variable 'expect'.
../../../packages/wdio-jasmine-framework/node_modules/expect-[secure]/types/jest-global.d.ts(3,15): error TS2451: Cannot redeclare block-scoped variable 'expect'.
jasmine.ts(18,25): error TS2339: Property 'toHaveTitle' does not exist on type 'Matchers<BrowserObject>'.
jasmine.ts(21,20): error TS2339: Property 'toHaveTextContaining' does not exist on type 'Matchers<Element>'.
../../../packages/wdio-jasmine-framework/node_modules/@types/jasmine/ts3.1/index.d.ts(112,18): error TS2451: Cannot redeclare block-scoped variable 'expect'.
../../../packages/wdio-jasmine-framework/node_modules/@types/jasmine/ts3.1/index.d.ts(119,18): error TS2451: Cannot redeclare block-scoped variable 'expect'.
../../../packages/wdio-jasmine-framework/node_modules/@types/jasmine/ts3.1/index.d.ts(126,18): error TS2451: Cannot redeclare block-scoped variable 'expect'.
../../../packages/wdio-jasmine-framework/node_modules/@types/jasmine/ts3.1/index.d.ts(131,18): error TS2451: Cannot redeclare block-scoped variable 'expect'.
../../../packages/wdio-jasmine-framework/node_modules/expect-[secure]/types/jest-global.d.ts(3,15): error TS2451: Cannot redeclare block-scoped variable 'expect'.

@mgrybyk
Copy link
Member

mgrybyk commented Apr 28, 2020

On it :)

@christian-bromann
Copy link
Member Author

On it :)

Feel free to push directly on this branch. Thanks!

@mgrybyk
Copy link
Member

mgrybyk commented Apr 28, 2020

Two issues here, on in expect-webdriverio, another one here. Working on PR for expect-webdriverio

@christian-bromann
Copy link
Member Author

@mgrybyk I will make a release for expect-webdriverio with your fix.

@mgrybyk mgrybyk closed this Apr 28, 2020
@mgrybyk mgrybyk reopened this Apr 28, 2020
@mgrybyk
Copy link
Member

mgrybyk commented Apr 28, 2020

@christian-bromann some unit tests are failing, not related to types now, so we are good :)

@christian-bromann
Copy link
Member Author

unit test failures are legit, looking into it.

@mikerusso-tsi
Copy link

The issue here seems related to what I'm seeing when webdriverio is used via Appium. It fires exceptions of "expect is not a function".

@christian-bromann
Copy link
Member Author

@mikerusso-tsi until we release this patch please add expect-webdriverio to your types as described in https://webdriver.io/docs/typescript.html#framework-types

Copy link
Member

@mgrybyk mgrybyk left a comment

Choose a reason for hiding this comment

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

Let's merge?

@christian-bromann christian-bromann merged commit 5bb5399 into master Apr 28, 2020
@christian-bromann christian-bromann deleted the cb-expect-typings branch April 28, 2020 22:10
@christian-bromann
Copy link
Member Author

Thanks for the help @mgrybyk , releasing it now.

@mikerusso-tsi
Copy link

@mikerusso-tsi until we release this patch please add expect-webdriverio to your types as described in https://webdriver.io/docs/typescript.html#framework-types

Thanks for your reply, @christian-bromann, I added it to the tsconfig.json of my appium client but still see the error. Pardon my ignorance on this, but, does appium make use of one of your framework adapters? I simply have an appium client in a node-based javascript file and am not making use of jasmine, mocha, or cucumber. Should expect-webdriverio be available in such case? I tried installing expect-webdriverio to the project and requiring it, but to no avail. When using appium, is the WDIO testrunner invoked (which is the piece that is said to include expect-webdriverio)? Thank you!

@christian-bromann
Copy link
Member Author

@mikerusso-tsi if you use expect-webdriverio without the testrunner you need to import it as described here https://www.npmjs.com/package/expect-webdriverio#usage

@mikerusso-tsi
Copy link

mikerusso-tsi commented May 4, 2020 via email

@christian-bromann
Copy link
Member Author

@mikerusso-tsi just require the package anywhere before you first use it

@mikerusso-tsi
Copy link

mikerusso-tsi commented May 4, 2020 via email

@christian-bromann
Copy link
Member Author

oh, ok. I assumed it would be possible to use it without the testrunner but apparently you can only use it with that.

@mikerusso-tsi
Copy link

mikerusso-tsi commented May 6, 2020 via email

@christian-bromann
Copy link
Member Author

Or, can you suggest any other means of using expect-webdriverio with Appium?

You can use the library with Appium. You just need to run WebdriverIO with the testrunner. You could also try to set browser as global:

global.browser = await remote({...})

await expect(browser).toHaveTitle()

@mikerusso-tsi
Copy link

mikerusso-tsi commented May 7, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Bug Fix 🐛 PRs that contain bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants