Something went wrong. Try again.
Identities for entities did.bot
agent llm did
Something went wrong. Try again.
JavaScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455// Shared helpers for the site's own test scripts. Kept dependency-light// (linkedom for HTML parsing is the one exception, since hand-rolling that// with regexes is how a link checker grows its own bugs).import { readFileSync, readdirSync, statSync } from "node:fs";import { dirname, join, resolve } from "node:path";import { fileURLToPath } from "node:url";import { parseHTML } from "linkedom";
export const here = dirname(fileURLToPath(import.meta.url));export const siteRoot = resolve(here, "..");export const repoRoot = resolve(siteRoot, "..");export const distDir = join(siteRoot, "dist");
export function requireDist() { try { statSync(distDir); } catch { throw new Error( `${distDir} does not exist — run "npm run build" in site/ before the tests`, ); }}
export function walkHtmlFiles(dir = distDir) { const out = []; for (const entry of readdirSync(dir, { withFileTypes: true })) { const full = join(dir, entry.name); if (entry.isDirectory()) { out.push(...walkHtmlFiles(full)); } else if (entry.name.endsWith(".html")) { out.push(full); } } return out;}
export function loadDocument(path) { const html = readFileSync(path, "utf8"); return parseHTML(html).document;}
let failures = 0;export function fail(message) { failures += 1; console.error(`FAIL: ${message}`);}
export function report(name) { if (failures > 0) { console.error(`\n${name}: ${failures} failure(s)`); process.exit(1); } console.log(`${name}: ok`);}