Skip to content

Commit 27f7227

Browse files
committed
test: speed up tests by only delaying 'late page' by 2 seconds
1 parent cead9af commit 27f7227

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

test/fixture/element-handles.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ test.describe('lib/fixture.ts', () => {
202202

203203
test('should handle the findBy* methods', async ({queries}) => {
204204
const {findByText} = queries
205-
expect(await findByText('Loaded!', {}, {timeout: 7000})).toBeTruthy()
205+
expect(await findByText('Loaded!', {}, {timeout: 3000})).toBeTruthy()
206206
})
207207

208208
test('should handle the findByAll* methods', async ({queries}) => {
209209
const {findAllByText} = queries
210-
const elements = await findAllByText(/Hello/, {}, {timeout: 7000})
210+
const elements = await findAllByText(/Hello/, {}, {timeout: 3000})
211211
expect(elements).toHaveLength(2)
212212

213213
const text = await Promise.all([elements[0].textContent(), elements[1].textContent()])

test/fixture/locators.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,21 @@ test.describe('lib/fixture.ts (locators)', () => {
180180
test.afterEach(async ({page}) => page.close())
181181

182182
test('should handle the findBy* methods', async ({queries}) => {
183-
const locator = await queries.findByText('Loaded!', undefined, {timeout: 7000})
183+
const locator = await queries.findByText('Loaded!', undefined, {timeout: 3000})
184184

185185
expect(await locator.textContent()).toEqual('Loaded!')
186186
})
187187

188188
test('should handle the findAllBy* methods', async ({queries}) => {
189-
const locator = await queries.findAllByText(/Hello/, undefined, {timeout: 7000})
189+
const locator = await queries.findAllByText(/Hello/, undefined, {timeout: 3000})
190190

191191
const text = await Promise.all([locator.nth(0).textContent(), locator.nth(1).textContent()])
192192

193193
expect(text).toEqual(['Hello h1', 'Hello h2'])
194194
})
195195

196196
test('throws Testing Library error when locator times out', async ({queries}) => {
197-
const query = async () => queries.findByText(/Loaded!/, undefined, {timeout: 1000})
197+
const query = async () => queries.findByText(/Loaded!/, undefined, {timeout: 500})
198198

199199
await expect(query).rejects.toThrowError(
200200
expect.objectContaining({
@@ -204,7 +204,7 @@ test.describe('lib/fixture.ts (locators)', () => {
204204
})
205205

206206
test('throws Testing Library error when multi-element locator times out', async ({queries}) => {
207-
const query = async () => queries.findAllByText(/Hello/, undefined, {timeout: 1000})
207+
const query = async () => queries.findAllByText(/Hello/, undefined, {timeout: 500})
208208

209209
await expect(query).rejects.toThrowError(
210210
expect.objectContaining({
@@ -214,7 +214,7 @@ test.describe('lib/fixture.ts (locators)', () => {
214214
})
215215

216216
test.describe('configuring asynchronous queries via `use`', () => {
217-
test.use({asyncUtilTimeout: 7000})
217+
test.use({asyncUtilTimeout: 3000})
218218

219219
test('reads timeout configuration from `use` configuration', async ({queries, page}) => {
220220
// Ensure this test fails if we don't set `timeout` correctly in the `waitFor` in our find query
@@ -232,7 +232,7 @@ test.describe('lib/fixture.ts (locators)', () => {
232232
await expect(queries.getByText('Hidden')).toBeHidden()
233233

234234
const locator = await queries.findByText('Hidden', undefined, {
235-
timeout: 7000,
235+
timeout: 3000,
236236
state: 'visible',
237237
})
238238

@@ -245,7 +245,7 @@ test.describe('lib/fixture.ts (locators)', () => {
245245
test('waits for hidden element to be visible', async ({queries}) => {
246246
await expect(queries.getByText('Hidden')).toBeHidden()
247247

248-
const locator = await queries.findByText('Hidden', undefined, {timeout: 7000})
248+
const locator = await queries.findByText('Hidden', undefined, {timeout: 3000})
249249

250250
expect(await locator.textContent()).toEqual('Hidden')
251251
})
@@ -257,7 +257,7 @@ test.describe('lib/fixture.ts (locators)', () => {
257257
await expect(queries.queryByText('Attached')).toHaveCount(0)
258258

259259
const locator = await queries.findByText('Attached', undefined, {
260-
timeout: 7000,
260+
timeout: 3000,
261261
state: 'attached',
262262
})
263263

@@ -271,7 +271,7 @@ test.describe('lib/fixture.ts (locators)', () => {
271271
test('waits for hidden element to be attached', async ({queries}) => {
272272
await expect(queries.queryByText('Attached')).toHaveCount(0)
273273

274-
const locator = await queries.findByText('Attached', undefined, {timeout: 7000})
274+
const locator = await queries.findByText('Attached', undefined, {timeout: 3000})
275275

276276
expect(await locator.textContent()).toEqual('Attached')
277277
await expect(locator).toBeHidden()

test/fixtures/late-page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
attached.textContent = 'Attached'
2525
attached.style.visibility = 'hidden'
2626
document.body.appendChild(attached)
27-
}, 5000)
27+
}, 2000)
2828
</script>
2929
</body>
3030
</html>

test/standalone/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('lib/index.ts', () => {
179179
afterEach(async () => page.goto(`file://${path.join(__dirname, '../fixtures/page.html')}`))
180180

181181
it('supports configuring timeout for findBy* queries', async () => {
182-
configure({asyncUtilTimeout: 9000})
182+
configure({asyncUtilTimeout: 3000})
183183

184184
const element = await queries.findByText(await getDocument(page), 'Loaded!')
185185

0 commit comments

Comments
 (0)