@@ -4,6 +4,7 @@ import * as path from "path";
44import { exec , spawn , ChildProcess } from "child_process" ;
55import { promisify } from "util" ;
66import { verifyFixtureIntegrity } from "./fixture-integrity.js" ;
7+ import * as os from "node:os" ;
78
89const execAsync = promisify ( exec ) ;
910
@@ -72,21 +73,6 @@ function killProcessTree(proc: ChildProcess): void {
7273 }
7374}
7475
75- // TODO (AleksandrSl 16/12/2025): Could we use helpers from src?
76- async function isPortInUse ( port : number ) : Promise < boolean > {
77- try {
78- const response = await fetch ( `http://localhost:${ port } ` ) ;
79- return true ; // If we get any response, port is in use
80- } catch ( e : any ) {
81- // ECONNREFUSED means port is not in use
82- if ( e . code === "ECONNREFUSED" ) {
83- return false ;
84- }
85- // Other errors might mean port is in use but not responding
86- return true ;
87- }
88- }
89-
9076export type Framework = "next" | "vite" ;
9177
9278export interface TestFixtureOptions {
@@ -164,20 +150,12 @@ export async function setupFixture(
164150 // Both Next.js and Vite are configured to use port 3000 in the demo apps
165151 const port = 3000 ;
166152
167- // Check if port is already in use
168- if ( await isPortInUse ( port ) ) {
169- throw new Error (
170- `Port ${ port } is already in use. Please free it before starting dev server.` ,
171- ) ;
172- }
173-
174153 console . log ( `Starting dev server for ${ framework } on port ${ port } ...` ) ;
175-
176- const isWindows = process . platform === "win32" ;
154+ const isWindows = os . platform ( ) === "win32" ;
177155 const devProcess = spawn ( isWindows ? "pnpm.cmd" : "pnpm" , [ "dev" ] , {
178156 cwd : fixturePath ,
179157 stdio : "pipe" ,
180- shell : true ,
158+ shell : isWindows ,
181159 detached : ! isWindows , // Use process groups on Unix
182160 } ) ;
183161
@@ -265,22 +243,13 @@ export async function setupFixture(
265243 async startProduction ( ) : Promise < ProdServer > {
266244 const port = framework === "next" ? 3000 : 4173 ;
267245
268- // Check if port is already in use
269- if ( await isPortInUse ( port ) ) {
270- throw new Error (
271- `Port ${ port } is already in use. Please free it before starting production server.` ,
272- ) ;
273- }
274-
275- console . log (
276- `Starting production server for ${ framework } on port ${ port } ...` ,
277- ) ;
246+ console . log ( `Starting production server for ${ framework } ...` ) ;
278247
279- const isWindows = process . platform === "win32" ;
248+ const isWindows = os . platform ( ) === "win32" ;
280249 const prodProcess = spawn ( isWindows ? "pnpm.cmd" : "pnpm" , [ "start" ] , {
281250 cwd : fixturePath ,
282251 stdio : "pipe" ,
283- shell : true ,
252+ shell : isWindows ,
284253 detached : ! isWindows ,
285254 } ) ;
286255
0 commit comments