Skip to content

Commit

Permalink
FIx before hook giving TS error with NightwatchBrowser. (#4004)
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 committed Jan 25, 2024
1 parent 1798bba commit ba2ad45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ export interface NightwatchAPI
// tslint:disable-next-line:no-empty-interface
export interface NightwatchCustomPageObjects { }

/**
* @deprecated Use `NightwatchAPI` instead.
*/
export interface NightwatchBrowser
extends NightwatchAPI,
NightwatchComponentTestingCommands,
Expand Down Expand Up @@ -636,7 +639,7 @@ export interface NightwatchTestFunctions {
}

export type NightwatchTestHook = (
browser: NightwatchAPI,
browser: NightwatchBrowser,
done: (err?: unknown) => void
) => void;

Expand Down
9 changes: 6 additions & 3 deletions types/tests/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
NightwatchAPI,
NightwatchAssertion,
NightwatchAssertionsResult,
NightwatchBrowser,
NightwatchClient,
NightwatchClientObject,
NightwatchEnsureResult,
Expand Down Expand Up @@ -283,10 +284,14 @@ describe('duckduckgo example', function () {
// .tests/native/wikipedia.ts
//
const wikipediaAppTest: NightwatchTests = {
before: (client: NightwatchAPI) => {
before: (client: NightwatchBrowser) => {
client.click(by.xpath('//XCUIElementTypeButton[@name="Skip"]'));
},

after: (client: NightwatchAPI) => {
client.end();
},

'Search for BrowserStack': async (client: NightwatchAPI) => {
client
.useXpath()
Expand Down Expand Up @@ -347,8 +352,6 @@ const wikipediaAppTest: NightwatchTests = {
})
.useCss()
.assert.textEquals('.pcs-edit-section-title', 'BrowserStack'); // command run in webview context

client.end();
},
};

Expand Down

0 comments on commit ba2ad45

Please sign in to comment.