fix: allow setting server config from fresh config (#1889)

This commit is contained in:
Marvin Hagemeister
2023-10-09 13:59:30 +02:00
committed by GitHub
parent 4fac2a22a6
commit 32eb61c95d
11 changed files with 266 additions and 6 deletions
+95
View File
@@ -5,6 +5,7 @@ import {
assertMatch,
assertStringIncludes,
delay,
join,
puppeteer,
retry,
} from "./deps.ts";
@@ -971,3 +972,97 @@ Deno.test("De-duplicates <Head /> nodes by key", async () => {
assert(/<meta property="og:title" content="Other title"\/>/.test(html));
});
});
Deno.test("pass options in config", async (t) => {
const fixture = join(Deno.cwd(), "tests", "fixture_config");
await t.step("config.onListen", async () => {
const { lines, serverProcess, output } = await startFreshServer({
args: [
"run",
"-A",
join(fixture, "main.ts"),
],
});
try {
assert(output.find((line) => line === "it works"));
} finally {
serverProcess.kill("SIGTERM");
await serverProcess.status;
// Drain the lines stream
for await (const _ of lines) { /* noop */ }
}
});
await t.step("config.server.onListen", async () => {
const { lines, serverProcess, output } = await startFreshServer({
args: [
"run",
"-A",
join(fixture, "main.ts"),
],
env: {
TEST_CONFIG_SERVER: "true",
},
});
try {
assert(output.find((line) => line === "it works #2"));
} finally {
serverProcess.kill("SIGTERM");
await serverProcess.status;
// Drain the lines stream
for await (const _ of lines) { /* noop */ }
}
});
});
Deno.test("pass options in config dev.ts", async (t) => {
const fixture = join(Deno.cwd(), "tests", "fixture_config");
await t.step("config.onListen", async () => {
const { lines, serverProcess, output } = await startFreshServer({
args: [
"run",
"-A",
join(fixture, "dev.ts"),
],
});
try {
assert(output.find((line) => line === "it works"));
} finally {
serverProcess.kill("SIGTERM");
await serverProcess.status;
// Drain the lines stream
for await (const _ of lines) { /* noop */ }
}
});
await t.step("config.server.onListen", async () => {
const { lines, serverProcess, output } = await startFreshServer({
args: [
"run",
"-A",
join(fixture, "dev.ts"),
],
env: {
TEST_CONFIG_SERVER: "true",
},
});
try {
assert(output.find((line) => line === "it works #2"));
} finally {
serverProcess.kill("SIGTERM");
await serverProcess.status;
// Drain the lines stream
for await (const _ of lines) { /* noop */ }
}
});
});