Skip to content

Commit 13a44f0

Browse files
committed
test(fixture): add coverage for custom test ID with find queries
1 parent 348344b commit 13a44f0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

test/fixture/locators.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,19 @@ test.describe('lib/fixture.ts (locators)', () => {
250250

251251
expect(await locator.textContent()).toEqual('Loaded!')
252252
})
253+
254+
test.describe('with custom test ID attribute from `use`', () => {
255+
test.use({testIdAttribute: 'data-customid'})
256+
257+
test('reads test ID configuration from `use` configuration', async ({queries, page}) => {
258+
// Ensure this test fails if we don't set `timeout` correctly in the `waitFor` in our find query
259+
page.setDefaultTimeout(4000)
260+
261+
const locator = await queries.findByTestId('loaded')
262+
263+
expect(await locator.textContent()).toEqual('Loaded!')
264+
})
265+
})
253266
})
254267

255268
test('waits for hidden element to be visible when `visible` is passed for state', async ({

test/fixtures/late-page.html

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
setTimeout(() => {
88
const loaded = document.createElement('span')
99
loaded.textContent = 'Loaded!'
10+
loaded.dataset.customid = 'loaded'
1011
document.body.appendChild(loaded)
1112

1213
const heading1 = document.createElement('h1')

0 commit comments

Comments
 (0)