Skip to content

Commit

Permalink
test: make brittle test more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
nvlang committed May 13, 2024
1 parent 2a2094c commit a4f9943
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/utils/cdn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ suite('utils/cdn', async () => {
it.each([
[
'https://httpstat.us/418',
3000,
1000,
undefined,
"HTTP error 418 \\(I'm a teapot\\): https://httpstat.us/418",
],
Expand All @@ -47,7 +47,7 @@ suite('utils/cdn', async () => {
],
])(
'fetchWithTimeout(%o, %o) === %o',
{ timeout: 2500, retry: 1 },
{ timeout: 1500, retry: 1 },
async (url, timeout, expected, logMessage) => {
expect(await fetchWithTimeout(url, timeout)).toEqual(expected);
if (logMessage) {
Expand All @@ -56,7 +56,9 @@ suite('utils/cdn', async () => {
1,
expect.stringMatching(/error|warn/),
expect.stringMatching(
new RegExp(`(${logMessage}|Timed out.*)`),
new RegExp(
`(${logMessage}|Timed out.*|HTTP error 503 (Service Unavailable): https://httpstat.us/418)`,
),
),
);
}
Expand Down

0 comments on commit a4f9943

Please sign in to comment.