blob: 140bb90b737df0055c8cc8aa04d162e2fcef3380 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import { expect } from "chai";
import { fileURLToPath } from "node:url";
import { astroCli, wranglerCli } from "./_test-utils.js";
const root = new URL("./fixtures/wasm-function-per-route/", import.meta.url);
describe("Wasm function per route import", () => {
let wrangler;
before(async () => {
await astroCli(fileURLToPath(root), "build");
wrangler = wranglerCli(fileURLToPath(root));
await new Promise((resolve) => {
wrangler.stdout.on("data", (data) => {
console.log("[stdout]", data.toString());
if (data.toString().includes("http://127.0.0.1:8788")) resolve();
});
wrangler.stderr.on("data", (data) => {
console.log("[stderr]", data.toString());
});
});
});
after((done) => {
wrangler.kill();
setTimeout(() => {
console.log("CLEANED");
done();
}, 1000);
});
it("can render", async () => {
let res = await fetch(`http://127.0.0.1:8788/`);
expect(res.status).to.equal(200);
let json = await res.json();
expect(json).to.deep.equal({ answer: 42 });
res = await fetch(`http://127.0.0.1:8788/deeply/nested/route`);
expect(res.status).to.equal(200);
json = await res.json();
expect(json).to.deep.equal({ answer: 84 });
});
});
|