( describeBlock: Circus.DescribeBlock, rng: RandomNumberGenerator | undefined, )
| 70 | } |
| 71 | |
| 72 | const _runTestsForDescribeBlock = async ( |
| 73 | describeBlock: Circus.DescribeBlock, |
| 74 | rng: RandomNumberGenerator | undefined, |
| 75 | ) => { |
| 76 | await dispatch({describeBlock, name: 'run_describe_start'}); |
| 77 | const {beforeAll, afterAll} = getAllHooksForDescribe(describeBlock); |
| 78 | |
| 79 | const isSkipped = describeBlock.mode === 'skip'; |
| 80 | |
| 81 | if (!isSkipped) { |
| 82 | for (const hook of beforeAll) { |
| 83 | await _callCircusHook({describeBlock, hook}); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // Tests that fail and are retried we run after other tests |
| 88 | const retryTimes = |
| 89 | Number.parseInt((globalThis as Global.Global)[RETRY_TIMES] as string, 10) || |
| 90 | 0; |
| 91 | const hasRetryTimes = retryTimes > 0; |
| 92 | |
| 93 | const waitBeforeRetry = |
| 94 | Number.parseInt( |
| 95 | (globalThis as Global.Global)[WAIT_BEFORE_RETRY] as string, |
| 96 | 10, |
| 97 | ) || 0; |
| 98 | |
| 99 | const retryImmediately: boolean = |
| 100 | ((globalThis as Global.Global)[RETRY_IMMEDIATELY] as any) || false; |
| 101 | |
| 102 | const deferredRetryTests: Array<Circus.TestEntry> = []; |
| 103 | |
| 104 | if (rng) { |
| 105 | describeBlock.children = shuffleArray(describeBlock.children, rng); |
| 106 | } |
| 107 | // Regroup concurrent tests as a single "sequential" unit |
| 108 | const children = regroupConcurrentChildren(describeBlock.children); |
| 109 | |
| 110 | const rerunTest = async (test: Circus.TestEntry) => { |
| 111 | let numRetriesAvailable = retryTimes; |
| 112 | |
| 113 | while (numRetriesAvailable > 0 && test.errors.length > 0) { |
| 114 | // Clear errors so retries occur |
| 115 | await dispatch({name: 'test_retry', test}); |
| 116 | |
| 117 | if (waitBeforeRetry > 0) { |
| 118 | await new Promise(resolve => setTimeout(resolve, waitBeforeRetry)); |
| 119 | } |
| 120 | |
| 121 | await _runTest(test, isSkipped); |
| 122 | numRetriesAvailable--; |
| 123 | } |
| 124 | }; |
| 125 | |
| 126 | const handleRetry = async ( |
| 127 | test: Circus.TestEntry, |
| 128 | hasErrorsBeforeTestRun: boolean, |
| 129 | hasRetryTimes: boolean, |
no test coverage detected