import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import test from "node:test"; async function renderHome() { const workerUrl = new URL("../dist/server/index.js", import.meta.url); workerUrl.searchParams.set("test", `${process.pid}-${Date.now()}`); const { default: worker } = await import(workerUrl.href); return worker.fetch( new Request("http://localhost/", { headers: { accept: "text/html" }, }), { ASSETS: { fetch: async () => new Response("Not found", { status: 404 }), }, }, { waitUntil() {}, passThroughOnException() {}, }, ); } test("首页可正常服务端渲染正式称重界面", async () => { const response = await renderHome(); assert.equal(response.status, 200); assert.match(response.headers.get("content-type") ?? "", /^text\/html\b/i); const html = await response.text(); assert.match(html, /