|
1 | | -import {waitFor, waitForElementToBeRemoved} from '..' |
| 1 | +import {configure,waitFor, waitForElementToBeRemoved} from '..' |
2 | 2 | import {render} from './helpers/test-utils'
|
3 | 3 |
|
4 | 4 | async function runWaitFor({time = 300} = {}, options) {
|
@@ -43,6 +43,23 @@ test('fake timer timeout', async () => {
|
43 | 43 | ).rejects.toMatchInlineSnapshot(`[Error: always throws]`)
|
44 | 44 | })
|
45 | 45 |
|
| 46 | +test('fake timer timeout uses default ontimeout', async () => { |
| 47 | + configure({ |
| 48 | + defaultOnTimeout: _ => { |
| 49 | + return Error('Test Error') |
| 50 | + }, |
| 51 | + }) |
| 52 | + jest.useFakeTimers() |
| 53 | + await expect( |
| 54 | + waitFor( |
| 55 | + () => { |
| 56 | + throw new Error('always throws') |
| 57 | + }, |
| 58 | + {timeout: 10}, |
| 59 | + ), |
| 60 | + ).rejects.toMatchInlineSnapshot(`[Error: Test Error]`) |
| 61 | +}) |
| 62 | + |
46 | 63 | test('times out after 1000ms by default', async () => {
|
47 | 64 | const startReal = performance.now()
|
48 | 65 | jest.useFakeTimers()
|
|
0 commit comments