Skip to content

Commit 16e0c59

Browse files
committed
tests: add scoped test
1 parent e69a91d commit 16e0c59

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

test/extend.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ describe('lib/extend.ts', () => {
5252
expect(text).toEqual(['Hello h1', 'Hello h2'])
5353
})
5454

55+
it('should scope results to element', async () => {
56+
const scope = await document.$('#scoped')
57+
const element = await scope.queryByText(/Hello/)
58+
expect(await page.evaluate(el => el.textContent, element)).toEqual('Hello h3')
59+
})
60+
5561
afterAll(async () => {
5662
await browser.close()
5763
})

test/fixtures/page.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ <h2>Hello h2</h2>
88
<input type="text" data-testid="testid-text-input">
99
<label for="label-text-input">Label A</label>
1010
<input id="label-text-input" type="text">
11+
12+
<div id="scoped">
13+
<h3>Hello h3</h3>
14+
</div>
1115
</body>
1216

1317
</html>

0 commit comments

Comments
 (0)