Skip to content

Commit 67793f8

Browse files
surface timeout + waitFor callback calls
1 parent 55ff2f2 commit 67793f8

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

src/__tests__/wait-for.js

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,14 @@ test('does not work after it resolves', async () => {
337337

338338
let data = null
339339
setTimeout(() => {
340+
contextStack.push('timeout')
340341
data = 'resolved'
341342
}, 100)
342343

343344
contextStack.push('waitFor:start')
344345
await waitFor(
345346
() => {
347+
contextStack.push('callback')
346348
// eslint-disable-next-line jest/no-conditional-in-test -- false-positive
347349
if (data === null) {
348350
throw new Error('not found')
@@ -352,27 +354,39 @@ test('does not work after it resolves', async () => {
352354
)
353355
contextStack.push('waitFor:end')
354356

355-
expect(contextStack).toEqual([
356-
'waitFor:start',
357-
'no-act:start',
358-
'act:start',
359-
'act:end',
360-
'act:start',
361-
'act:end',
362-
'no-act:end',
363-
'waitFor:end',
364-
])
357+
expect(contextStack).toMatchInlineSnapshot(`
358+
[
359+
waitFor:start,
360+
no-act:start,
361+
callback,
362+
act:start,
363+
act:end,
364+
callback,
365+
act:start,
366+
timeout,
367+
act:end,
368+
callback,
369+
no-act:end,
370+
waitFor:end,
371+
]
372+
`)
365373

366374
await Promise.resolve()
367375

368-
expect(contextStack).toEqual([
369-
'waitFor:start',
370-
'no-act:start',
371-
'act:start',
372-
'act:end',
373-
'act:start',
374-
'act:end',
375-
'no-act:end',
376-
'waitFor:end',
377-
])
376+
expect(contextStack).toMatchInlineSnapshot(`
377+
[
378+
waitFor:start,
379+
no-act:start,
380+
callback,
381+
act:start,
382+
act:end,
383+
callback,
384+
act:start,
385+
timeout,
386+
act:end,
387+
callback,
388+
no-act:end,
389+
waitFor:end,
390+
]
391+
`)
378392
})

0 commit comments

Comments
 (0)