Skip to content

Commit

Permalink
fix(browser): relax locator selectors methods (#7422)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored Feb 4, 2025
1 parent 2abf053 commit 1b8c5c9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/browser/context.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,38 +288,38 @@ interface LocatorSelectors {
* 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).
* @see {@link https://vitest.dev/guide/browser/locators#getbyrole}
*/
getByRole(role: ARIARole | ({} & string), options?: LocatorByRoleOptions): Locator
getByRole: (role: ARIARole | ({} & string), options?: LocatorByRoleOptions) => Locator
/**
* @see {@link https://vitest.dev/guide/browser/locators#getbylabeltext}
*/
getByLabelText(text: string | RegExp, options?: LocatorOptions): Locator
getByLabelText: (text: string | RegExp, options?: LocatorOptions) => Locator
/**
* 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.
* @see {@link https://vitest.dev/guide/browser/locators#getbyalttext}
*/
getByAltText(text: string | RegExp, options?: LocatorOptions): Locator
getByAltText: (text: string | RegExp, options?: LocatorOptions) => Locator
/**
* 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`.
* @see {@link https://vitest.dev/guide/browser/locators#getbyplaceholder}
*/
getByPlaceholder(text: string | RegExp, options?: LocatorOptions): Locator
getByPlaceholder: (text: string | RegExp, options?: LocatorOptions) => Locator
/**
* 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`.
* Matching by text always normalizes whitespace, even with exact match.
* For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.
* @see {@link https://vitest.dev/guide/browser/locators#getbytext}
*/
getByText(text: string | RegExp, options?: LocatorOptions): Locator
getByText: (text: string | RegExp, options?: LocatorOptions) => Locator
/**
* 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.
* @see {@link https://vitest.dev/guide/browser/locators#getbytitle}
*/
getByTitle(text: string | RegExp, options?: LocatorOptions): Locator
getByTitle: (text: string | RegExp, options?: LocatorOptions) => Locator
/**
* 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).
* @see {@link https://vitest.dev/guide/browser/locators#getbytestid}
*/
getByTestId(text: string | RegExp): Locator
getByTestId: (text: string | RegExp) => Locator
}

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

/**
* Make a screenshot of an element matching the locator.
Expand Down

0 comments on commit 1b8c5c9

Please sign in to comment.