Skip to content

Commit 7381d20

Browse files
committed
make network errors fail the test
1 parent 932ceeb commit 7381d20

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

utils/helpers.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,24 +660,21 @@ export const validateLinks = async (page: Page, urls: Set<string>, currentHost:
660660
const status = response.status();
661661
const isExternal = new URL(url).host !== currentHost;
662662

663-
// Handle client errors (4xx)
664663
if (status >= 400 && status < 500) {
665-
// External 401/403 are expected (auth-gated), skip them
666664
if (!(isExternal && (status === 401 || status === 403))) {
667665
brokenLinks.push(`${status}: ${url}`);
668666
}
669667
}
670668

671-
// Log server errors (5xx) but don't fail
672669
if (status >= 500) {
673670
// eslint-disable-next-line no-console
674671
console.warn(`Warning: ${url} returned ${status} (server error, not failing test)`);
675672
}
676673
} catch (error: unknown) {
677-
// Network errors (timeout, DNS, connection) - log but don't fail
678674
const msg = error instanceof Error ? error.message : String(error);
675+
brokenLinks.push(`NETWORK: ${url} (${msg})`);
679676
// eslint-disable-next-line no-console
680-
console.warn(`Warning: Network error for ${url}: ${msg}`);
677+
console.warn(`Network error for ${url}: ${msg}`);
681678
}
682679
}
683680

0 commit comments

Comments
 (0)