Skip to content

Commit 35a27d4

Browse files
authored
fix: add Locator as a possible element type in toContainElement() matcher (fix #8910) (#8927)
1 parent 751c392 commit 35a27d4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/guide/browser/assertion-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ await expect.element(page.getByText('Vitest')).toBeInViewport({ ratio: 1 })
324324
## toContainElement
325325

326326
```ts
327-
function toContainElement(element: HTMLElement | SVGElement | null): Promise<void>
327+
function toContainElement(element: HTMLElement | SVGElement | Locator | null): Promise<void>
328328
```
329329

330330
This allows you to assert whether an element contains another element as a descendant or not.

packages/browser/jest-dom.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Disable automatic exports.
22

33
import { ARIARole } from './aria-role.ts'
4-
import { ScreenshotComparatorRegistry, ScreenshotMatcherOptions } from './context.js'
4+
import { Locator, ScreenshotComparatorRegistry, ScreenshotMatcherOptions } from './context.js'
55

66
export interface TestingLibraryMatchers<E, R> {
77
/**
@@ -207,7 +207,7 @@ export interface TestingLibraryMatchers<E, R> {
207207
* await expect.element(ancestor).not.toContainElement(nonExistentElement)
208208
* @see https://vitest.dev/guide/browser/assertion-api#tocontainelement
209209
*/
210-
toContainElement(element: HTMLElement | SVGElement | null): R
210+
toContainElement(element: HTMLElement | SVGElement | Locator | null): R
211211
/**
212212
* @description
213213
* Assert whether a string representing a HTML element is contained in another element.

0 commit comments

Comments
 (0)