webchat: improve logging and static serving
This commit is contained in:
@@ -30,6 +30,11 @@ const fetchText = (url: string) =>
|
||||
.on("error", reject);
|
||||
});
|
||||
|
||||
const fetchHeaders = (url: string) =>
|
||||
new Promise<http.IncomingHttpHeaders>((resolve, reject) => {
|
||||
http.get(url, (res) => resolve(res.headers)).on("error", reject);
|
||||
});
|
||||
|
||||
describe("webchat server (static only)", () => {
|
||||
test("serves index.html over loopback", { timeout: 8000 }, async () => {
|
||||
const port = await getFreePort();
|
||||
@@ -41,4 +46,17 @@ describe("webchat server (static only)", () => {
|
||||
await stopWebChatServer();
|
||||
}
|
||||
});
|
||||
|
||||
test("serves bundled JS with module-friendly content type", async () => {
|
||||
const port = await getFreePort();
|
||||
await startWebChatServer(port);
|
||||
try {
|
||||
const headers = await fetchHeaders(
|
||||
`http://127.0.0.1:${port}/webchat.bundle.js`,
|
||||
);
|
||||
expect(headers["content-type"]).toContain("application/javascript");
|
||||
} finally {
|
||||
await stopWebChatServer();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user