Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#68767 Fix/k6 browser 1.3.0 type definition…
Browse files Browse the repository at this point in the history
…s by @ankur22
  • Loading branch information
ankur22 authored Mar 6, 2024
1 parent 054f0ec commit 5684af0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions types/k6/experimental/browser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,10 @@ export interface ElementHandle extends JSHandle {
* @param selector A selector to query for.
* @param options Wait options.
*/
waitForSelector(selector: string, options?: { state?: ElementState } & StrictnessOptions & TimeoutOptions): void;
waitForSelector(
selector: string,
options?: { state?: ElementState } & StrictnessOptions & TimeoutOptions,
): ElementHandle;
}

/**
Expand Down Expand Up @@ -3370,7 +3373,7 @@ export interface Page {
* To wait for an element on the page, use locator.waitFor([options]).
* @param selector A selector to query for.
*/
$(selector: string): ElementHandle;
$(selector: string): ElementHandle | null;

/**
* **NOTE** Use locator-based page.locator(selector[, options]) instead.
Expand Down
12 changes: 6 additions & 6 deletions types/k6/test/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ page.workers();

// @ts-expect-error
page.$();
// $ExpectType ElementHandle
// $ExpectType ElementHandle | null
page.$(selector);

// @ts-expect-error
Expand Down Expand Up @@ -1273,7 +1273,7 @@ response.then(r => r?.url());
// ElementHandle
//

const elementHandle = page.$(selector);
const elementHandle = page.waitForSelector(selector);

// @ts-expect-error
elementHandle.$();
Expand Down Expand Up @@ -1475,13 +1475,13 @@ elementHandle.waitForElementState("visible", { timeout: 10000 });

// @ts-expect-error
elementHandle.waitForSelector();
// $ExpectType void
// $ExpectType ElementHandle
elementHandle.waitForSelector("div");
// $ExpectType void
// $ExpectType ElementHandle
elementHandle.waitForSelector("div", { timeout: 10000 });
// $ExpectType void
// $ExpectType ElementHandle
elementHandle.waitForSelector("div", { state: "attached" });
// $ExpectType void
// $ExpectType ElementHandle
elementHandle.waitForSelector("div", { strict: true });

//
Expand Down

0 comments on commit 5684af0

Please sign in to comment.