chore(tests): use to spin up server (#1261)

This commit is contained in:
Marvin Hagemeister
2023-06-09 11:27:56 +02:00
committed by GitHub
parent 5724b73e71
commit 894f56b9c9
5 changed files with 18 additions and 117 deletions
+3 -21
View File
@@ -5,10 +5,10 @@ import {
assertStringIncludes,
delay,
puppeteer,
TextLineStream,
} from "./deps.ts";
import manifest from "./fixture_plugin/fresh.gen.ts";
import options from "./fixture_plugin/options.ts";
import { startFreshServer } from "./test_utils.ts";
const ctx = await ServerContext.fromManifest(manifest, options);
const handler = ctx.handler();
@@ -62,27 +62,9 @@ Deno.test({
name: "/with-island hydration",
async fn(t) {
// Preparation
const serverProcess = new Deno.Command(Deno.execPath(), {
const { lines, serverProcess } = await startFreshServer({
args: ["run", "-A", "./tests/fixture_plugin/main.ts"],
stdout: "piped",
stderr: "inherit",
}).spawn();
const decoder = new TextDecoderStream();
const lines = serverProcess.stdout
.pipeThrough(decoder)
.pipeThrough(new TextLineStream());
let started = false;
for await (const line of lines) {
if (line.includes("Listening on http://")) {
started = true;
break;
}
}
if (!started) {
throw new Error("Server didn't start up");
}
});
await delay(100);