@@ -176,19 +176,8 @@ error with a stack
176
176
expect ( stderr ) . toMatch ( / b u n d l e d - l i b \/ s r c \/ b .j s : 2 : ( 8 | 1 8 ) / )
177
177
expect ( stderr ) . toMatch ( / b u n d l e d - l i b \/ s r c \/ i n d e x .j s : 5 : ( 1 5 | 1 7 ) / )
178
178
179
- if ( provider === 'playwright' ) {
180
- // page.getByRole('code').click()
181
- expect ( stderr ) . toContain ( 'locator.click: Timeout' )
182
- // playwright error is proxied from the server to the client and back correctly
183
- expect ( stderr ) . toContain ( 'waiting for locator(\'[data-vitest="true"]\').contentFrame().getByRole(\'code\')' )
184
- expect ( stderr ) . toMatch ( / t e s t \/ f a i l i n g .t e s t .t s : 2 7 : ( 3 3 | 3 9 ) / )
185
- // await expect.element().toBeVisible()
186
- expect ( stderr ) . toContain ( 'Cannot find element with locator: getByRole(\'code\')' )
187
- expect ( stderr ) . toMatch ( / t e s t \/ f a i l i n g .t e s t .t s : 3 1 : ( 4 9 | 6 1 ) / )
188
- }
189
-
190
179
// index() is called from a bundled file
191
- expect ( stderr ) . toMatch ( / t e s t \/ f a i l i n g .t e s t .t s : 3 6 : ( 2 | 8 ) / )
180
+ expect ( stderr ) . toMatch ( / t e s t \/ f a i l i n g .t e s t .t s : 2 5 : ( 2 | 8 ) / )
192
181
} )
193
182
194
183
test ( 'popup apis should log a warning' , ( ) => {
@@ -219,7 +208,7 @@ test('user-event', async () => {
219
208
} )
220
209
} )
221
210
222
- test ( 'timeout' , async ( ) => {
211
+ test ( 'timeout settings ' , async ( ) => {
223
212
const { stderr } = await runBrowserTests ( {
224
213
root : './fixtures/timeout' ,
225
214
} )
@@ -232,3 +221,144 @@ test('timeout', async () => {
232
221
expect ( stderr ) . toContain ( 'Cannot find element with locator' )
233
222
}
234
223
} )
224
+
225
+ test . runIf ( provider === 'playwright' ) ( 'timeout hooks' , async ( ) => {
226
+ const { stderr } = await runBrowserTests ( {
227
+ root : './fixtures/timeout-hooks' ,
228
+ } )
229
+
230
+ const lines = stderr . split ( '\n' )
231
+ const timeoutErrorsIndexes = [ ]
232
+ lines . forEach ( ( line , index ) => {
233
+ if ( line . includes ( 'TimeoutError:' ) ) {
234
+ timeoutErrorsIndexes . push ( index )
235
+ }
236
+ } )
237
+
238
+ const snapshot = timeoutErrorsIndexes . map ( ( index ) => {
239
+ return [
240
+ lines [ index - 1 ] ,
241
+ lines [ index ] . replace ( / T i m e o u t \d + m s e x c e e d e d / , 'Timeout <ms> exceeded' ) ,
242
+ lines [ index + 4 ] ,
243
+ ] . join ( '\n' )
244
+ } ) . sort ( ) . join ( '\n\n' )
245
+
246
+ expect ( snapshot ) . toMatchInlineSnapshot ( `
247
+ " FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > afterAll
248
+ TimeoutError: locator.click: Timeout <ms> exceeded.
249
+ ❯ hooks-timeout.test.ts:44:45
250
+
251
+ FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped
252
+ TimeoutError: locator.click: Timeout <ms> exceeded.
253
+ ❯ hooks-timeout.test.ts:26:45
254
+
255
+ FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll
256
+ TimeoutError: locator.click: Timeout <ms> exceeded.
257
+ ❯ hooks-timeout.test.ts:35:45
258
+
259
+ FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped
260
+ TimeoutError: locator.click: Timeout <ms> exceeded.
261
+ ❯ hooks-timeout.test.ts:17:45
262
+
263
+ FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails
264
+ TimeoutError: locator.click: Timeout <ms> exceeded.
265
+ ❯ hooks-timeout.test.ts:7:33
266
+
267
+ FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails
268
+ TimeoutError: locator.click: Timeout <ms> exceeded.
269
+ ❯ hooks-timeout.test.ts:70:47
270
+
271
+ FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global
272
+ TimeoutError: locator.click: Timeout <ms> exceeded.
273
+ ❯ hooks-timeout.test.ts:79:47
274
+
275
+ FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails
276
+ TimeoutError: locator.click: Timeout <ms> exceeded.
277
+ ❯ hooks-timeout.test.ts:54:47
278
+
279
+ FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global
280
+ TimeoutError: locator.click: Timeout <ms> exceeded.
281
+ ❯ hooks-timeout.test.ts:61:47
282
+
283
+ FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > afterAll
284
+ TimeoutError: locator.click: Timeout <ms> exceeded.
285
+ ❯ hooks-timeout.test.ts:44:45
286
+
287
+ FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped
288
+ TimeoutError: locator.click: Timeout <ms> exceeded.
289
+ ❯ hooks-timeout.test.ts:26:45
290
+
291
+ FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll
292
+ TimeoutError: locator.click: Timeout <ms> exceeded.
293
+ ❯ hooks-timeout.test.ts:35:45
294
+
295
+ FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped
296
+ TimeoutError: locator.click: Timeout <ms> exceeded.
297
+ ❯ hooks-timeout.test.ts:17:45
298
+
299
+ FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails
300
+ TimeoutError: locator.click: Timeout <ms> exceeded.
301
+ ❯ hooks-timeout.test.ts:7:33
302
+
303
+ FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails
304
+ TimeoutError: locator.click: Timeout <ms> exceeded.
305
+ ❯ hooks-timeout.test.ts:70:47
306
+
307
+ FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global
308
+ TimeoutError: locator.click: Timeout <ms> exceeded.
309
+ ❯ hooks-timeout.test.ts:79:47
310
+
311
+ FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails
312
+ TimeoutError: locator.click: Timeout <ms> exceeded.
313
+ ❯ hooks-timeout.test.ts:54:47
314
+
315
+ FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global
316
+ TimeoutError: locator.click: Timeout <ms> exceeded.
317
+ ❯ hooks-timeout.test.ts:61:47
318
+
319
+ FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > afterAll
320
+ TimeoutError: locator.click: Timeout <ms> exceeded.
321
+ ❯ hooks-timeout.test.ts:44:51
322
+
323
+ FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped
324
+ TimeoutError: locator.click: Timeout <ms> exceeded.
325
+ ❯ hooks-timeout.test.ts:26:51
326
+
327
+ FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll
328
+ TimeoutError: locator.click: Timeout <ms> exceeded.
329
+ ❯ hooks-timeout.test.ts:35:51
330
+
331
+ FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped
332
+ TimeoutError: locator.click: Timeout <ms> exceeded.
333
+ ❯ hooks-timeout.test.ts:17:51
334
+
335
+ FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails
336
+ TimeoutError: locator.click: Timeout <ms> exceeded.
337
+ ❯ hooks-timeout.test.ts:7:39
338
+
339
+ FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails
340
+ TimeoutError: locator.click: Timeout <ms> exceeded.
341
+ ❯ hooks-timeout.test.ts:70:53
342
+
343
+ FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global
344
+ TimeoutError: locator.click: Timeout <ms> exceeded.
345
+ ❯ hooks-timeout.test.ts:79:53
346
+
347
+ FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails
348
+ TimeoutError: locator.click: Timeout <ms> exceeded.
349
+ ❯ hooks-timeout.test.ts:54:53
350
+
351
+ FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global
352
+ TimeoutError: locator.click: Timeout <ms> exceeded.
353
+ ❯ hooks-timeout.test.ts:61:53"
354
+ ` )
355
+
356
+ // page.getByRole('code').click()
357
+ expect ( stderr ) . toContain ( 'locator.click: Timeout' )
358
+ // playwright error is proxied from the server to the client and back correctly
359
+ expect ( stderr ) . toContain ( 'waiting for locator(\'[data-vitest="true"]\').contentFrame().getByRole(\'code\')' )
360
+ expect ( stderr ) . toMatch ( / h o o k s - t i m e o u t .t e s t .t s : 7 : ( 3 3 | 3 9 ) / )
361
+ // await expect.element().toBeVisible()
362
+ expect ( stderr ) . toContain ( 'Cannot find element with locator: getByRole(\'code\')' )
363
+ expect ( stderr ) . toMatch ( / h o o k s - t i m e o u t .t e s t .t s : 1 1 : ( 4 9 | 6 1 ) / )
364
+ } , 120_000 * 3 )
0 commit comments