@@ -48,6 +48,8 @@ type CDPServer = {
4848export type StartClient = ( options ?: {
4949 clientName ?: string ,
5050 args ?: string [ ] ,
51+ omitArgs ?: string [ ] ,
52+ cwd ?: string ,
5153 config ?: Config ,
5254 roots ?: { name : string , uri : string } [ ] ,
5355 rootsResponseDelay ?: number ,
@@ -84,14 +86,14 @@ export const test = serverTest.extend<TestFixtures & TestOptions, WorkerFixtures
8486 const clients : Client [ ] = [ ] ;
8587
8688 await use ( async options => {
87- const args : string [ ] = mcpArgs ?? [ ] ;
89+ let args : string [ ] = mcpArgs ?? [ ] ;
8890
8991 if ( mcpHeadless )
9092 args . push ( '--headless' ) ;
9193
9294 if ( mcpServerType === 'test-mcp' ) {
9395 if ( ! options ?. args ?. some ( arg => arg . startsWith ( '--config' ) ) )
94- args . push ( ' --config' , test . info ( ) . outputPath ( ) ) ;
96+ args . push ( ` --config= ${ test . info ( ) . outputPath ( ) } ` ) ;
9597 } else {
9698 if ( process . env . CI && process . platform === 'linux' )
9799 args . push ( '--no-sandbox' ) ;
@@ -106,6 +108,8 @@ export const test = serverTest.extend<TestFixtures & TestOptions, WorkerFixtures
106108
107109 if ( options ?. args )
108110 args . push ( ...options . args ) ;
111+ if ( options ?. omitArgs )
112+ args = args . filter ( arg => ! options . omitArgs ?. includes ( arg ) ) ;
109113
110114 const client = new Client ( { name : options ?. clientName ?? 'test' , version : '1.0.0' } , options ?. roots ? { capabilities : { roots : { } } } : undefined ) ;
111115 if ( options ?. roots ) {
@@ -118,7 +122,7 @@ export const test = serverTest.extend<TestFixtures & TestOptions, WorkerFixtures
118122 } ) ;
119123 }
120124 const env = { ...process . env , ...options ?. env } ;
121- const { transport, stderr } = await createTransport ( mcpServerType , args , env ) ;
125+ const { transport, stderr } = await createTransport ( mcpServerType , { args, env, cwd : options ?. cwd || test . info ( ) . outputPath ( ) } ) ;
122126 let stderrBuffer = '' ;
123127 stderr ?. on ( 'data' , data => {
124128 if ( process . env . PWDEBUGIMPL )
@@ -182,18 +186,18 @@ export const test = serverTest.extend<TestFixtures & TestOptions, WorkerFixtures
182186 mcpServerType : [ 'mcp' , { option : true } ] ,
183187} ) ;
184188
185- async function createTransport ( mcpServerType : TestOptions [ 'mcpServerType' ] , args : string [ ] , env : NodeJS . ProcessEnv ) : Promise < {
189+ async function createTransport ( mcpServerType : TestOptions [ 'mcpServerType' ] , options : { args : string [ ] , env : NodeJS . ProcessEnv , cwd : string } ) : Promise < {
186190 transport : Transport ,
187191 stderr : Stream | null ,
188192} > {
189193 const profilesDir = test . info ( ) . outputPath ( 'ms-playwright' ) ;
190194 const transport = new StdioClientTransport ( {
191195 command : 'node' ,
192- args : [ ...( mcpServerType === 'test-mcp' ? testMcpServerPath : mcpServerPath ) , ...args ] ,
193- cwd : test . info ( ) . outputPath ( ) ,
196+ args : [ ...( mcpServerType === 'test-mcp' ? testMcpServerPath : mcpServerPath ) , ...options . args ] ,
197+ cwd : options . cwd ,
194198 stderr : 'pipe' ,
195199 env : {
196- ...env ,
200+ ...options . env ,
197201 DEBUG_COLORS : '0' ,
198202 DEBUG_HIDE_DATE : '1' ,
199203 PWMCP_PROFILES_DIR_FOR_TEST : profilesDir ,
0 commit comments