Skip to content

Commit ef69aee

Browse files
fix(tests): import in fetch state fn
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
1 parent d73ade6 commit ef69aee

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

test/builtins/fetch.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import { createServer } from "node:net";
1+
import { URL, fileURLToPath } from 'node:url';
2+
import { createServer } from 'node:net';
23

34
import { strictEqual, ok } from 'node:assert';
4-
import { getRandomPort } from "../util";
55

66
const FETCH_URL = 'http://localhost';
77

88
export const state = async () => {
9+
const { getRandomPort } = await import(
10+
fileURLToPath(new URL('../util.js', import.meta.url))
11+
);
912
const port = await getRandomPort();
1013
return { port };
1114
};
@@ -29,14 +32,18 @@ export const enableFeatures = ['http'];
2932
export async function test(run, testState) {
3033
// Get the randomly generated port
3134
const port = testState.port;
32-
if (!port) { throw new Error("missing port on test state"); }
35+
if (!port) {
36+
throw new Error('missing port on test state');
37+
}
3338

3439
// Run a local server on some port
3540
const server = createServer(async (req, res) => {
36-
res.writeHead(200, { "Content-Type": "application/json; charset=utf-8" });
37-
res.write(JSON.stringify({
38-
status: "ok",
39-
}));
41+
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
42+
res.write(
43+
JSON.stringify({
44+
status: 'ok',
45+
}),
46+
);
4047
res.end();
4148
}).listen(port);
4249

0 commit comments

Comments
 (0)