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

can we have support async/await for wdio-intercept-service #598

Open
LakshmiYaswanth opened this issue Jun 25, 2023 · 7 comments
Open

can we have support async/await for wdio-intercept-service #598

LakshmiYaswanth opened this issue Jun 25, 2023 · 7 comments
Labels

Comments

@LakshmiYaswanth
Copy link

LakshmiYaswanth commented Jun 25, 2023

can we have support async/await for wdio-intercept-service

@christian-bromann
Copy link
Contributor

Can you explained in a bit more detail what you mean by that?

@tehhowch
Copy link
Contributor

@LakshmiYaswanth Please provide more detail in your question / request. What would be extremely helpful is if you could provide an example of asynchronous code using wdio-intercept-service that you would like to have work, but which does not currently work.

@Grobouls
Copy link

Maybe I can help:
Using typescript, I am not able to have my esLint able to infer the correct returned type of browser.getRequests() etc. etc.

I can see that the signature will depend if web

here are the types used in tsConfig:

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

My dev dependencies:
"devDependencies": { "@angular/animations": "^16.2.1", "@angular/cdk": "^16.2.1", "@angular/common": "^16.2.1", "@angular/core": "^16.2.1", "@angular/forms": "^16.2.1", "@angular/material": "^16.2.1", "@angular/platform-browser": "^16.2.1", "@badisi/wdio-harness": "^3.0.3", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.3.0", "@typescript-eslint/parser": "^6.3.0", "@wdio/cli": "^8.14.6", "@wdio/config": "^8.14.6", "@wdio/cucumber-framework": "^8.14.6", "@wdio/globals": "^8.14.6", "@wdio/local-runner": "^8.14.6", "@wdio/logger": "^8.11.0", "@wdio/spec-reporter": "^8.14.0", "@wdio/static-server-service": "^8.14.0", "eslint": "^8.47.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "^2.28.0", "eslint-plugin-prettier": "^5.0.0", "eslint-plugin-wdio": "^8.8.7", "http-server": "^14.1.1", "jest": "^29.6.2", "jest-circus": "^29.6.2", "npm-run-all": "^4.1.5", "prettier": "^3.0.2", "rxjs": "^7.8.1", "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "typescript": "^5.1.6", "wdio-intercept-service": "^4.4.0", "webdriverio": "^8.14.6", "zone.js": "^0.13.1" }

At runtime, indeed promises are always returned by this plugin function but during compilation i keep getting eslint complaining that "await has no effect on this instruction"....everywhere...

Can you advise ? May I bring more details ?

@tehhowch
Copy link
Contributor

tehhowch commented Sep 5, 2023

Sounds like this is a duplicate of #229

@lacell75
Copy link

Hello @christian-bromann , I have the same issue . I can't use this service in TS file.
Unexpected `await` of a non-Promise (non-"Thenable") value.eslint[@typescript-eslint/await-thenable](https://typescript-eslint.io/rules/await-thenable) (method) WebdriverIO.Browser.getRequests(options?: (WdioInterceptorService.GetRequestOptions & WdioInterceptorService.OnlyCompletedRequests) | undefined): WdioInterceptorService.CompletedRequest[] (+1 overload)

My types are correctly configured:
"types": ["node", "@wdio/globals/types", "@wdio/mocha-framework", "@wdio/cucumber-framework", "expect-webdriverio", "wdio-intercept-service"],

I think the types are not correctly seen by typescript
My snippet code:
const requestreturn = await browser.getRequests();

@christian-bromann
Copy link
Contributor

@lacell75 this package does not provide any types. If anyone wants to contribute this, that would be awesome, thank you!

@tehhowch
Copy link
Contributor

@lacell75 that looks like just an ESLint error, just disable it. It's perfectly fine to await something that isn't a promise. And indeed, the return value truly is a promise, so your code is correct as-is -- just the lint issue caused by #229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants