Unverified Commit 3a41ddb5 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Fix check utility in tests (#12678)

parent 4c23bac3
...@@ -342,6 +342,7 @@ export async function startCleanStaticServer(dir) { ...@@ -342,6 +342,7 @@ export async function startCleanStaticServer(dir) {
// 30 seconds // 30 seconds
export async function check(contentFn, regex, hardError = true) { export async function check(contentFn, regex, hardError = true) {
let content let content
let lastErr
for (let tries = 0; tries < 30; tries++) { for (let tries = 0; tries < 30; tries++) {
try { try {
...@@ -352,19 +353,14 @@ export async function check(contentFn, regex, hardError = true) { ...@@ -352,19 +353,14 @@ export async function check(contentFn, regex, hardError = true) {
} }
await waitFor(1000) await waitFor(1000)
} catch (err) { } catch (err) {
if (tries === 30) { await waitFor(1000)
console.error('Error while getting content', { regex }, err) lastErr = err
}
} }
} }
console.error('TIMED OUT CHECK: ', { regex, content }) console.error('TIMED OUT CHECK: ', { regex, content, lastErr })
if (hardError) { if (hardError) {
// maintain previous behavior where the error is thrown in a timeout
// and isn't caught when wrapped in a try/catch
setTimeout(() => {
throw new Error('TIMED OUT: ' + regex + '\n\n' + content) throw new Error('TIMED OUT: ' + regex + '\n\n' + content)
}, 1)
} }
return false return false
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment