Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import { existsSync, readFileSync, rmSync } from "node:fs";
import type { FullConfig } from "@playwright/test";
import { SERVER_CONSOLE_ENV } from "./server.ts";
/** Fails the run on anything the built server logged, which no browser fixture can see. */
const teardown = (config: FullConfig) => {
const path = config.webServer?.env?.[SERVER_CONSOLE_ENV];
if (!path) return;
if (!existsSync(path)) {
throw new Error(
"The server never recorded its console: call recordServerConsole() in its preload",
);
}
const output = readFileSync(path, "utf8").trim();
rmSync(path);
if (output) throw new Error(`The server logged during the e2e run:\n\n${output}`);
};
export default teardown;
|