Skip to content

Commit 00f7d22

Browse files
fix: types when using wdio v7.9
Upgrade dev dependencies to use wdio v7.9. WebdriverIO v7.9 introduces chainable promise elements as a way of replacing sync mode since it is not supported by Node v16. Change $ selectors to allow returning a ChainablePromiseElement. In order to continue supporting wdio v6 and sync mode $ should also allow returning a normal Promise<Element> and an Element respectively. When support for either is dropped the respective return values can also be removed from $.
1 parent 887f5c1 commit 00f7d22

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
"@types/simmerjs": "^0.5.1",
3939
"@typescript-eslint/eslint-plugin": "^4.14.0",
4040
"@typescript-eslint/parser": "^4.14.0",
41-
"@wdio/cli": "^7.3.1",
42-
"@wdio/local-runner": "^7.3.1",
43-
"@wdio/mocha-framework": "^7.3.1",
44-
"@wdio/selenium-standalone-service": "^7.7.3",
45-
"@wdio/spec-reporter": "^7.3.1",
46-
"@wdio/sync": "^7.3.1",
41+
"@wdio/cli": "^7.9.0",
42+
"@wdio/local-runner": "^7.9.0",
43+
"@wdio/mocha-framework": "^7.9.0",
44+
"@wdio/selenium-standalone-service": "^7.9.0",
45+
"@wdio/spec-reporter": "^7.9.0",
46+
"@wdio/sync": "^7.9.0",
4747
"eslint": "^7.6.0",
4848
"kcd-scripts": "^11.1.0",
4949
"npm-run-all": "^4.1.5",

src/wdio-types.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@ declare global {
1515
}
1616
}
1717

18+
export type $ = (
19+
selector: any,
20+
) =>
21+
| ChainablePromiseElementBase<Promise<WebdriverIO.Element>>
22+
| Promise<WebdriverIO.Element>
23+
| WebdriverIO.Element
24+
25+
export type ChainablePromiseElementBase<T> = Promise<T> & {$: $}
26+
1827
export type ElementBase = {
19-
$(
20-
selector: object | string,
21-
): Promise<WebdriverIO.Element> | WebdriverIO.Element
28+
$: $
2229

2330
execute<T>(
2431
script: string | ((...args: any[]) => T),
@@ -31,9 +38,7 @@ export type ElementBase = {
3138
}
3239

3340
export type BrowserBase = {
34-
$(
35-
selector: object | string,
36-
): Promise<WebdriverIO.Element> | WebdriverIO.Element
41+
$: $
3742

3843
addCommand<T extends boolean>(
3944
queryName: string,

0 commit comments

Comments
 (0)