nightwatch icon indicating copy to clipboard operation
nightwatch copied to clipboard

Support for Async/Await in @types/nightwatch

Open vaibhavsingh97 opened this issue 2 years ago • 3 comments

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

vaibhavsingh97 avatar Jul 26 '22 13:07 vaibhavsingh97

#3300

AutomatedTester avatar Jul 29 '22 08:07 AutomatedTester

Adding to this, if we write it('some title', async () => {}), Typescript infers the passed function as NormalFunc instead of AsyncFunc.

garg3133 avatar Aug 02 '22 09:08 garg3133

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]

garg3133 avatar Sep 06 '22 10:09 garg3133