Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit 8ffc39f

Browse files
committed
test(fixture): add test for getQueriesForElement as well
1 parent 8defba6 commit 8ffc39f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/fixture/fixture.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as path from 'path'
22
import * as playwright from '@playwright/test'
33

44
import {configure, fixtures, TestingLibraryFixtures} from '../../lib/fixture'
5-
import {getDocument, within} from '../../lib'
5+
import {getDocument, within, getQueriesForElement} from '../../lib'
66

77
const test = playwright.test.extend<TestingLibraryFixtures>(fixtures)
88

@@ -155,6 +155,14 @@ test.describe('lib/fixture.ts', () => {
155155
expect(await queryByText('Hello h3')).toBeTruthy()
156156
})
157157

158+
test('scoping queries with `getQueriesForElement`', async ({queries: {getByTestId}}) => {
159+
// eslint-disable-next-line @typescript-eslint/unbound-method
160+
const {queryByText} = getQueriesForElement(await getByTestId('scoped'))
161+
162+
expect(await queryByText('Hello h1')).toBeFalsy()
163+
expect(await queryByText('Hello h3')).toBeTruthy()
164+
})
165+
158166
test.describe('configuration', () => {
159167
test.afterEach(() => {
160168
configure({testIdAttribute: 'data-testid'}) // cleanup

0 commit comments

Comments
 (0)