Skip to content

Commit 1b8c5c9

Browse files
authoredFeb 4, 2025··
fix(browser): relax locator selectors methods (#7422)
1 parent 2abf053 commit 1b8c5c9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
 

‎packages/browser/context.d.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -288,38 +288,38 @@ interface LocatorSelectors {
288288
* Creates a way to locate an element by its [ARIA role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles), [ARIA attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes) and [accessible name](https://developer.mozilla.org/en-US/docs/Glossary/Accessible_name).
289289
* @see {@link https://vitest.dev/guide/browser/locators#getbyrole}
290290
*/
291-
getByRole(role: ARIARole | ({} & string), options?: LocatorByRoleOptions): Locator
291+
getByRole: (role: ARIARole | ({} & string), options?: LocatorByRoleOptions) => Locator
292292
/**
293293
* @see {@link https://vitest.dev/guide/browser/locators#getbylabeltext}
294294
*/
295-
getByLabelText(text: string | RegExp, options?: LocatorOptions): Locator
295+
getByLabelText: (text: string | RegExp, options?: LocatorOptions) => Locator
296296
/**
297297
* Creates a locator capable of finding an element with an `alt` attribute that matches the text. Unlike testing-library's implementation, Vitest will match any element that has an `alt` attribute.
298298
* @see {@link https://vitest.dev/guide/browser/locators#getbyalttext}
299299
*/
300-
getByAltText(text: string | RegExp, options?: LocatorOptions): Locator
300+
getByAltText: (text: string | RegExp, options?: LocatorOptions) => Locator
301301
/**
302302
* Creates a locator capable of finding an element that has the specified placeholder text. Vitest will match any element that has a matching `placeholder` attribute, not just `input`.
303303
* @see {@link https://vitest.dev/guide/browser/locators#getbyplaceholder}
304304
*/
305-
getByPlaceholder(text: string | RegExp, options?: LocatorOptions): Locator
305+
getByPlaceholder: (text: string | RegExp, options?: LocatorOptions) => Locator
306306
/**
307307
* Creates a locator capable of finding an element that contains the specified text. The text will be matched against TextNode's [`nodeValue`](https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeValue) or input's value if the type is `button` or `reset`.
308308
* Matching by text always normalizes whitespace, even with exact match.
309309
* For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.
310310
* @see {@link https://vitest.dev/guide/browser/locators#getbytext}
311311
*/
312-
getByText(text: string | RegExp, options?: LocatorOptions): Locator
312+
getByText: (text: string | RegExp, options?: LocatorOptions) => Locator
313313
/**
314314
* Creates a locator capable of finding an element that has the specified `title` attribute. Unlike testing-library's `getByTitle`, Vitest cannot find `title` elements within an SVG.
315315
* @see {@link https://vitest.dev/guide/browser/locators#getbytitle}
316316
*/
317-
getByTitle(text: string | RegExp, options?: LocatorOptions): Locator
317+
getByTitle: (text: string | RegExp, options?: LocatorOptions) => Locator
318318
/**
319319
* Creates a locator capable of finding an element that matches the specified test id attribute. You can configure the attribute name with [`browser.locators.testIdAttribute`](/config/#browser-locators-testidattribute).
320320
* @see {@link https://vitest.dev/guide/browser/locators#getbytestid}
321321
*/
322-
getByTestId(text: string | RegExp): Locator
322+
getByTestId: (text: string | RegExp) => Locator
323323
}
324324

325325
export interface Locator extends LocatorSelectors {
@@ -391,7 +391,7 @@ export interface Locator extends LocatorSelectors {
391391
* Change a file input element to have the specified files. Uses provider's API under the hood.
392392
* @see {@link https://vitest.dev/guide/browser/interactivity-api#userevent-upload}
393393
*/
394-
upload: (files: File | File[] | string | string[]) => Promise<void>
394+
upload(files: File | File[] | string | string[]): Promise<void>
395395

396396
/**
397397
* Make a screenshot of an element matching the locator.

0 commit comments

Comments
 (0)
Please sign in to comment.