Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748// A real, unmodified Express 5 app (demo/apps/express, pinned by its lockfile) runs in// the runtime from its snapshot with NODE_ENV=production, serving public/ through// express.static. tests/goldens/http/express.json is what the pinned Node answered for// the same requests (demo/apps/express/requests.json), recorded by `node scripts/golden.mjs`.import { test, expect, type Page } from "@playwright/test";import { appUrl, recordExchanges, type RecordedRequest } from "./http-golden";import { readGolden } from "../scripts/golden-files.ts";
const GOLDEN = readGolden("http", "express");
async function bootExpress(page: Page): Promise<string> { await page.goto("/demo/express.html"); await expect(page.frameLocator("#app").locator("#hi")).toBeVisible({ timeout: 20_000 }); return await appUrl(page);}
test("the iframe renders Express's HTML and the listen callback logs", async ({ page }) => { await bootExpress(page); await expect(page.frameLocator("#app").locator("#hi")).toHaveText("Hello from Express"); await expect(page.locator("#out")).toHaveText("listening on 3000\n");});
test("the page's stylesheet comes from express.static", async ({ page }) => { await bootExpress(page); const hi = page.frameLocator("#app").locator("#hi"); await expect(hi).toHaveCSS("color", "rgb(0, 128, 128)"); await expect(hi).toHaveCSS("font-family", "monospace");});
test("every exchange matches what Node answered, ETags and Last-Modified included", async ({ page }) => { const requests: RecordedRequest[] = await (await page.request.get(`/${GOLDEN.requests}`)).json(); const base = await bootExpress(page); expect(await recordExchanges(page, base, requests)).toEqual(GOLDEN.exchanges);});
test("a throwing route logs its stack once and the process stays alive", async ({ page }) => { const base = await bootExpress(page); const status = await page.evaluate(async (base) => (await fetch(base + "boom")).status, base); expect(status).toBe(500); await expect(page.locator("#err")).toContainText("Error: route failed"); const err = (await page.locator("#err").textContent()) ?? ""; expect(err.split("Error: route failed").length - 1).toBe(1); expect(err.split("\n")[1]).toMatch(/^ {4}at .*\/app\/server\.cjs:8:32\)?$/); const again = await page.evaluate(async (base) => (await fetch(base)).status, base); expect(again).toBe(200); await expect(page.locator("#exit")).toHaveText("…");});