Skip to content

Commit a1c99b6

Browse files
authored
tests: options interface that includes selector for extend queries (#43)
1 parent 3b90b33 commit a1c99b6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/extend.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ describe('lib/extend.ts', () => {
8282
expect(text).toEqual(['Hello h1', 'Hello h2', 'Hello h3'])
8383
})
8484

85+
it('should handle the queryAll* methods with a selector', async () => {
86+
const elements = await document.queryAllByText(/Hello/, {selector: 'h2'})
87+
expect(elements).toHaveLength(1)
88+
89+
const text = await page.evaluate(el => el.textContent, elements[0])
90+
91+
expect(text).toEqual('Hello h2')
92+
})
93+
94+
it('should handle the getBy* methods with a selector', async () => {
95+
const element = await document.getByText(/Hello/, {selector: 'h2'})
96+
97+
const text = await page.evaluate(el => el.textContent, element)
98+
99+
expect(text).toEqual('Hello h2')
100+
})
101+
85102
it('should scope results to element', async () => {
86103
const scope = await document.$('#scoped')
87104
const element = await scope!.queryByText(/Hello/)

0 commit comments

Comments
 (0)