Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
1234567891011121314151617181920// Record an app's WebSocket exchange under real Node for tests/goldens/ws// (scripts/golden.mjs drives it). The app runs as scripts/app-under-node.mjs starts it;// the exchange is the `exchange` export of the app's public/client.js (the same file the// app's page runs), driven by Node's global WebSocket against ws://localhost:<port>/live.import { join, resolve } from "node:path";import { pathToFileURL } from "node:url";import { startApp } from "./app-under-node.mjs";
/** `root` is the package root that `app` is relative to. Resolves with the log lines. */export async function recordWs(root, { app, port }, node) { const dir = resolve(root, app); const { exchange } = await import(pathToFileURL(join(dir, "public/client.js")).href); const running = await startApp(dir, port, node); try { return await exchange(WebSocket, `ws://localhost:${port}/live`); } finally { await running.stop(); }}