nightwatch
nightwatch copied to clipboard
Support for Async/Await in @types/nightwatch
Describe the bug
Since Nightwatch v2 release, @types/nightwatch
kind of broken return type and a lack of support of async/await
.
Test Code
const result = await browser.hasDescendants('.features-container');
Definitions
hasDescendants(
selector: Definition,
callback?: (this: NightwatchAPI, result: NightwatchCallbackResult<boolean>) => void,
): this;
hasDescendants(
using: LocateStrategy,
selector: Definition,
callback?: (this: NightwatchAPI, result: NightwatchCallbackResult<boolean>) => void,
): this;
Based on this type-definition, the result will always be this
(whatever it is). If we had used async/await
syntax, then it's not the boolean value that would be passed; instead this
will be returned, which is simply wrong.
Affected versions
v2.x
onwards
#3300
Adding to this, if we write it('some title', async () => {})
, Typescript infers the passed function as NormalFunc
instead of AsyncFunc
.
CDP Commands:
Issue: #3347 PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/61782 [MERGED]
ClientCommands and ElementCommands:
Issue: https://github.com/nightwatchjs/nightwatch/issues/3376 PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/62063 [MERGED]
WebDriverProtocol:
Issue: https://github.com/nightwatchjs/nightwatch/issues/3377 PR: In progress
Ensure:
Issue: #3375 PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/62067 [MERGED]
Assert:
Issue: #3374 PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/62126 [MERGED]
Expect:
Issue: #3363 PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/62138 [MERGED]