File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 1- import { createServer } from "node:net" ;
1+ import { URL , fileURLToPath } from 'node:url' ;
2+ import { createServer } from 'node:net' ;
23
34import { strictEqual , ok } from 'node:assert' ;
4- import { getRandomPort } from "../util" ;
55
66const FETCH_URL = 'http://localhost' ;
77
88export 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'];
2932export 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
You can’t perform that action at this time.
0 commit comments