webdriverio / visual-testing

Image comparison / visual regression testing for WebdriverIO
https://webdriver.io/docs/visual-testing
MIT License
110 stars 41 forks source link

Return types of some functions are not set to promises, and cause ESLint to throw an error #77

Closed c-trimm closed 2 years ago

c-trimm commented 2 years ago

Environment (please complete the following information):

Config of WebdriverIO + wdio-image-comparison-service tsconfig:

"types": [
    "node",
    "@wdio/cucumber-framework",
    "@wdio/devtools-service",
    "expect-webdriverio",
    "webdriverio/async"
],

Describe the bug The return types on some of the functions supplied by types/index.d.ts appear to be incorrect. The one I am currently encountering is for checkFullPageScreen. When writing await browser.checkFullPageScreen('...'), I receive the message

ESLint: Unexpected `await` of a non-Promise (non-"Thenable") value.(@typescript-eslint/await-thenable)

In the index.d.ts file, it has the return type as Result without a promise, while the actual function in webdriver-image-comparison has the return type of Promise<ImageCompareResult | number>.

To Reproduce Steps to reproduce the behavior:

Something like this will show the error if you have ESLint installed:

expect(await browser.checkFullPageScreen('viewer_textbox_default_text')).toEqual(0)

Expected behavior It should not show the error because if the return type supports promises, it will allow it to be awaited.

Log n/a

Additional context n/a

wswebcreation commented 2 years ago

Closing this one because it will be fixed with https://github.com/wswebcreation/wdio-image-comparison-service/pull/93