2021-06-28 22:13:35 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/ * *  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Copyright  ( c )  Microsoft  Corporation . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Licensed  under  the  Apache  License ,  Version  2.0  ( the  "License" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  you  may  not  use  this  file  except  in  compliance  with  the  License . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  You  may  obtain  a  copy  of  the  License  at 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  http : //www.apache.org/licenses/LICENSE-2.0
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Unless  required  by  applicable  law  or  agreed  to  in  writing ,  software 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  distributed  under  the  License  is  distributed  on  an  "AS IS"  BASIS , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  WITHOUT  WARRANTIES  OR  CONDITIONS  OF  ANY  KIND ,  either  express  or  implied . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  See  the  License  for  the  specific  language  governing  permissions  and 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  limitations  under  the  License . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * / 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  fs  from  'fs' ;  
						 
					
						
							
								
									
										
										
										
											2021-06-28 22:13:35 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								import  path  from  'path' ;  
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  test ,  expect ,  parseTestRunnerOutput  }  from  './playwright-test-fixtures' ;  
						 
					
						
							
								
									
										
										
										
											2021-06-28 22:13:35 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'it should not allow multiple tests with the same name per suite' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'tests/example.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-09 21:17:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test . describe ( 'suite' ,  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        test ( 'i-am-a-duplicate' ,  async  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test . describe ( 'suite' ,  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        test ( 'i-am-a-duplicate' ,  async  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-28 22:13:35 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 09:36:59 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` Error: duplicate test title ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` i-am-a-duplicate ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` tests ${ path . sep } example.spec.js:4 ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 09:36:59 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` tests ${ path . sep } example.spec.js:7 ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-28 22:13:35 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-11 11:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								test ( 'it should not allow multiple tests with the same name in multiple files' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'tests/example1.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-11 11:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'i-am-a-duplicate' ,  async  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'i-am-a-duplicate' ,  async  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'tests/example2.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-11 11:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'i-am-a-duplicate' ,  async  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'i-am-a-duplicate' ,  async  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 09:36:59 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Error: duplicate test title' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-07 15:11:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` test('i-am-a-duplicate' ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` tests ${ path . sep } example1.spec.js:3 ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` tests ${ path . sep } example1.spec.js:4 ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` tests ${ path . sep } example2.spec.js:3 ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` tests ${ path . sep } example2.spec.js:4 ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-11 11:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-28 22:13:35 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								test ( 'it should not allow a focused test when forbid-only is used' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-25 22:32:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    'playwright.config.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      module . exports  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        forbidOnly : true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-28 22:13:35 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    'tests/focused-test.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-28 22:13:35 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								      test . only ( 'i-am-focused' ,  async  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-25 22:32:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-28 22:13:35 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-25 22:32:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` Error: item focused with '.only' is not allowed due to the 'forbidOnly' option in 'playwright.config.ts':  \ "tests ${ path . sep } focused-test.spec.js i-am-focused \ " ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-07 15:11:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` test.only('i-am-focused' ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` tests ${ path . sep } focused-test.spec.js:3 ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-28 22:13:35 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 21:13:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								test ( 'should continue with other tests after worker process suddenly exits' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'passed1' ,  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'passed2' ,  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'failed1' ,  ( )  = >  {  process . exit ( 0 ) ;  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 21:13:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'passed3' ,  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'passed4' ,  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 21:13:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 4 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 15:43:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . failed ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 21:13:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . skipped ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 09:36:59 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Internal error: worker process exited unexpectedly' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								test ( 'sigint should stop workers' ,  async  ( {  interactWithTestRunner  } )  = >  {  
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  test . skip ( process . platform  ===  'win32' ,  'No sending SIGINT on Windows' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  testProcess  =  await  interactWithTestRunner ( { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    'a.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'interrupted1' ,  async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '\\n%%SEND-SIGINT%%1' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 21:11:02 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        await  new  Promise ( f  = >  setTimeout ( f ,  3000 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'skipped1' ,  async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '\\n%%skipped1' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'b.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'interrupted2' ,  async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '\\n%%SEND-SIGINT%%2' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 21:11:02 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        await  new  Promise ( f  = >  setTimeout ( f ,  3000 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'skipped2' ,  async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '\\n%%skipped2' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ,  {  'workers' :  2 ,  'reporter' :  'line,json'  } ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-08 14:23:35 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    PW_TEST_REPORTER : path.join ( __dirname ,  '../../packages/playwright/lib/reporters/json.js' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    PLAYWRIGHT_JSON_OUTPUT_NAME :  'report.json' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  testProcess . waitForOutput ( '%%SEND-SIGINT%%' ,  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  {  exitCode  }  =  await  testProcess . exited ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( exitCode ) . toBe ( 130 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  parseTestRunnerOutput ( testProcess . output ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . failed ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-02 12:55:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . skipped ) . toBe ( 2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . interrupted ) . toBe ( 2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( '%%SEND-SIGINT%%1' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( '%%SEND-SIGINT%%2' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( '%%skipped1' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( '%%skipped2' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-01 19:39:43 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Test was interrupted.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'Test timeout of' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-08 15:23:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  report  =  JSON . parse ( fs . readFileSync ( test . info ( ) . outputPath ( 'report.json' ) ,  'utf8' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  interrupted2  =  report . suites [ 1 ] . specs [ 0 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-08 15:23:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( interrupted2 . title ) . toBe ( 'interrupted2' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( interrupted2 . tests [ 0 ] . results [ 0 ] . workerIndex  ===  0  ||  interrupted2 . tests [ 0 ] . results [ 0 ] . workerIndex  ===  1 ) . toBe ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  skipped2  =  report . suites [ 1 ] . specs [ 1 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-08 15:23:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( skipped2 . title ) . toBe ( 'skipped2' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( skipped2 . tests [ 0 ] . results [ 0 ] . workerIndex ) . toBe ( - 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 12:04:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2021-07-08 18:24:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'should use the first occurring error when an unhandled exception was thrown' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'unhandled-exception.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      const  {  test : base ,  expect  }  =  require ( '@playwright/test' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      const  test  =  base . extend ( { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 18:24:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        context : async  ( { } ,  test )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          await  test ( 123 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          let  errorWasThrownPromiseResolve  =  ( )  = >  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          const  errorWasThrownPromise  =  new  Promise ( resolve  = >  errorWasThrownPromiseResolve  =  resolve ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          setTimeout ( ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            errorWasThrownPromiseResolve ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            throw  new  Error ( 'second error' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          } ,  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          await  errorWasThrownPromise ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        page : async  ( {  context } ,  test )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          throw  new  Error ( 'first error' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          await  test ( 123 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'my-test' ,  async  ( {  page  } )  = >  {  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . failed ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 12:51:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . report . suites [ 0 ] . specs [ 0 ] . tests [ 0 ] . results [ 0 ] . error ! . message ) . toBe ( 'first error' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 18:24:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2021-07-28 15:43:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								test ( 'worker interrupt should report errors' ,  async  ( {  interactWithTestRunner  } )  = >  {  
						 
					
						
							
								
									
										
										
										
											2021-07-28 15:43:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  test . skip ( process . platform  ===  'win32' ,  'No sending SIGINT on Windows' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  testProcess  =  await  interactWithTestRunner ( { 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    'a.spec.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      import  {  test  as  base ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      const  test  =  base . extend ( { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 15:43:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        throwOnTeardown : async  ( { } ,  use )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          let  reject ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          await  use ( new  Promise ( ( f ,  r )  = >  reject  =  r ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          reject ( new  Error ( 'INTERRUPT' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'interrupted' ,  async  ( {  throwOnTeardown  } )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '\\n%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  throwOnTeardown ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  testProcess . waitForOutput ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  {  exitCode  }  =  await  testProcess . exited ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( exitCode ) . toBe ( 130 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  parseTestRunnerOutput ( testProcess . output ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 15:43:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . failed ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-02 12:55:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . interrupted ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 15:43:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Error: INTERRUPT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2021-10-22 11:10:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'should not stall when workers are available' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-30 07:07:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      const  {  writeFile ,  waitForFile  }  =  require ( './utils.js' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'fails-1' ,  async  ( { } ,  testInfo )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  waitForFile ( testInfo ,  'lockA' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 11:10:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        console . log ( '\\n%%fails-1-started' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-30 07:07:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        writeFile ( testInfo ,  'lockB' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 11:10:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        console . log ( '\\n%%fails-1-done' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( 1 ) . toBe ( 2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-30 07:07:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'passes-1' ,  async  ( { } ,  testInfo )  = >  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 11:10:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        console . log ( '\\n%%passes-1' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-30 07:07:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        writeFile ( testInfo ,  'lockC' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 11:10:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'b.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-30 07:07:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      const  {  writeFile ,  waitForFile  }  =  require ( './utils.js' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'passes-2' ,  async  ( { } ,  testInfo )  = >  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 11:10:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        console . log ( '\\n%%passes-2-started' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-30 07:07:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        writeFile ( testInfo ,  'lockA' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  waitForFile ( testInfo ,  'lockB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  waitForFile ( testInfo ,  'lockC' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 11:10:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        console . log ( '\\n%%passes-2-done' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-30 07:07:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    'utils.js' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      const  fs  =  require ( 'fs' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      const  path  =  require ( 'path' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      function  fullName ( testInfo ,  file )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  path . join ( testInfo . config . projects [ 0 ] . outputDir ,  file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      async  function  waitForFile ( testInfo ,  file )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  fn  =  fullName ( testInfo ,  file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          if  ( fs . existsSync ( fn ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          await  new  Promise ( f  = >  setTimeout ( f ,  100 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      function  writeFile ( testInfo ,  file )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  fn  =  fullName ( testInfo ,  file ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        fs . mkdirSync ( path . dirname ( fn ) ,  {  recursive : true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        fs . writeFileSync ( fn ,  '0' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      module . exports  =  {  writeFile ,  waitForFile  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 11:10:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ,  {  workers : 2  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . failed ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-07 15:11:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . outputLines ) . toEqual ( [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'passes-2-started' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'fails-1-started' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'fails-1-done' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'passes-1' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'passes-2-done' , 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 11:10:37 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2022-02-14 10:57:15 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'should teardown workers that are redundant' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'helper.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      const  {  test : base ,  expect  }  =  require ( '@playwright/test' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      module . exports  =  base . extend ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 10:57:15 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        w :  [ async  ( { } ,  use )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( '\\n%%worker setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          await  use ( 'worker' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( '\\n%%worker teardown' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ,  {  scope :  'worker'  } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.js' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      const  test  =  require ( './helper' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'test1' ,  async  ( {  w  } )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  new  Promise ( f  = >  setTimeout ( f ,  1500 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '\\n%%test-done' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'b.spec.js' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      const  test  =  require ( './helper' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'test2' ,  async  ( {  w  } )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  new  Promise ( f  = >  setTimeout ( f ,  3000 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '\\n%%test-done' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ,  {  workers : 2  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-07 15:11:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . outputLines ) . toEqual ( [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'worker setup' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'worker setup' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'test-done' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'worker teardown' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'test-done' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'worker teardown' , 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 10:57:15 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2022-04-25 09:05:40 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'should not hang if test suites in worker are inconsistent with runner' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  oldValue  =  process . env . TEST_WORKER_INDEX ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  delete  process . env . TEST_WORKER_INDEX ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'playwright.config.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      module . exports  =  {  name :  'project-name'  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'names.js' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    exports . getNames  =  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      const  inWorker  =  process . env . TEST_WORKER_INDEX  !==  undefined ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      if  ( inWorker ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  [ 'foo' ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      return  [ 'foo' ,  'bar' ,  'baz' ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-25 09:05:40 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      const  {  getNames  }  =  require ( './names' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      const  names  =  getNames ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      for  ( const  index  in  names )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        test ( 'Test '  +  index  +  ' - '  +  names [ index ] ,  async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ,  {  'workers' :  1  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . env . TEST_WORKER_INDEX  =  oldValue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . failed ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . skipped ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-19 14:13:11 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . report . suites [ 0 ] . specs [ 1 ] . tests [ 0 ] . results [ 0 ] . error ! . message ) . toBe ( 'Test(s) not found in the worker process. Make sure test titles do not change:\nproject-name > a.spec.js > Test 1 - bar\nproject-name > a.spec.js > Test 2 - baz' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-25 09:05:40 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								test ( 'sigint should stop global setup' ,  async  ( {  interactWithTestRunner  } )  = >  {  
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  test . skip ( process . platform  ===  'win32' ,  'No sending SIGINT on Windows' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  testProcess  =  await  interactWithTestRunner ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    'playwright.config.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      module . exports  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        globalSetup :  './globalSetup' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        globalTeardown :  './globalTeardown.ts' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'globalSetup.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      module . exports  =  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( 'Global setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  new  Promise ( f  = >  setTimeout ( f ,  30000 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'globalTeardown.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      module . exports  =  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( 'Global teardown' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'test' ,  async  ( )  = >  {  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ,  {  'workers' :  1  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  testProcess . waitForOutput ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  {  exitCode  }  =  await  testProcess . exited ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( exitCode ) . toBe ( 130 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  parseTestRunnerOutput ( testProcess . output ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Global setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'Global teardown' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								test ( 'sigint should stop plugins' ,  async  ( {  interactWithTestRunner  } )  = >  {  
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  test . skip ( process . platform  ===  'win32' ,  'No sending SIGINT on Windows' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  testProcess  =  await  interactWithTestRunner ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    'playwright.config.ts' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-27 14:36:41 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      const  _plugins  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      _plugins . push ( ( )  = >  ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        setup : async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( 'Plugin1 setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          return  new  Promise ( f  = >  setTimeout ( f ,  30000 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        teardown : async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( 'Plugin1 teardown' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-27 14:36:41 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      _plugins . push ( ( )  = >  ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        setup : async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( 'Plugin2 setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        teardown : async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( 'Plugin2 teardown' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-27 14:36:41 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      module . exports  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        _plugins 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-20 17:16:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'test' ,  async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( 'testing!' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ,  {  'workers' :  1  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  testProcess . waitForOutput ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  {  exitCode  }  =  await  testProcess . exited ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( exitCode ) . toBe ( 130 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  parseTestRunnerOutput ( testProcess . output ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Plugin1 setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Plugin1 teardown' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'Plugin2 setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'Plugin2 teardown' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'testing!' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								test ( 'sigint should stop plugins 2' ,  async  ( {  interactWithTestRunner  } )  = >  {  
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  test . skip ( process . platform  ===  'win32' ,  'No sending SIGINT on Windows' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  testProcess  =  await  interactWithTestRunner ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    'playwright.config.ts' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-27 14:36:41 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      const  _plugins  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      _plugins . push ( ( )  = >  ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        setup : async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( 'Plugin1 setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        teardown : async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( 'Plugin1 teardown' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-27 14:36:41 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      _plugins . push ( ( )  = >  ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        setup : async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( 'Plugin2 setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          return  new  Promise ( f  = >  setTimeout ( f ,  30000 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        teardown : async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( 'Plugin2 teardown' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-27 14:36:41 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      module . exports  =  {  _plugins  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.js' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-20 17:16:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'test' ,  async  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( 'testing!' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ,  {  'workers' :  1  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  testProcess . waitForOutput ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  {  exitCode  }  =  await  testProcess . exited ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( exitCode ) . toBe ( 130 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  parseTestRunnerOutput ( testProcess . output ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 15:46:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Plugin1 setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Plugin2 setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Plugin1 teardown' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'Plugin2 teardown' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'testing!' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 12:06:00 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2022-07-06 12:51:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'should not crash with duplicate titles and .only' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'example.spec.ts' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 12:51:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'non unique title' ,  ( )  = >  {  console . log ( 'do not run me' ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test . skip ( 'non unique title' ,  ( )  = >  {  console . log ( 'do not run me' ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test . only ( 'non unique title' ,  ( )  = >  {  console . log ( 'do run me' ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 09:36:59 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` Error: duplicate test title ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-07 15:11:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` test('non unique title' ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` test.skip('non unique title' ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` test.only('non unique title' ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` example.spec.ts:3 ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` example.spec.ts:4 ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` example.spec.ts:5 ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 12:51:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'should not crash with duplicate titles and line filter' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'example.spec.ts' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 12:51:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      test ( 'non unique title' ,  ( )  = >  {  console . log ( 'do not run me' ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test . skip ( 'non unique title' ,  ( )  = >  {  console . log ( 'do not run me' ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'non unique title' ,  ( )  = >  {  console . log ( 'do run me' ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ,  { } ,  { } ,  {  additionalArgs :  [ 'example.spec.ts:6' ]  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 12:51:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 09:36:59 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` Error: duplicate test title ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-07 15:11:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` test('non unique title' ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` example.spec.ts:3 ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` example.spec.ts:4 ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( ` example.spec.ts:5 ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 12:51:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2022-11-22 16:22:48 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'should not load tests not matching filter' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.ts' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-22 16:22:48 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      console . log ( 'in a.spec.ts' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'test1' ,  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'example.spec.ts' :  ` 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 19:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-22 16:22:48 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      console . log ( 'in example.spec.ts' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'test2' ,  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ,  { } ,  { } ,  {  additionalArgs :  [ 'a.spec.ts' ]  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-07 15:11:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'in example.spec.ts' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'in a.spec.ts' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-22 16:22:48 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2023-03-03 07:49:19 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'should filter by sourcemapped file names' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 19:49:01 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    'gherkin.spec.js' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  test  }  from  '@playwright/test' ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'should run' ,  ( )  = >  { } ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdoZXJraW4uZmVhdHVyZSJdLCJuYW1lcyI6WyJOb25lIl0sIm1hcHBpbmdzIjoiQUFBQUE7QUFBQUE7QUFBQUE7QUFBQUE7QUFBQUE7QUFBQUEiLCJmaWxlIjoiZ2hlcmtpbi5mZWF0dXJlIiwic291cmNlc0NvbnRlbnQiOlsiVGVzdCJdfQ==`,
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'another.spec.js' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								throw  new  Error ( 'should not load another.spec.js' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFub3RoZXIuZmVhdHVyZSJdLCJuYW1lcyI6WyJOb25lIl0sIm1hcHBpbmdzIjoiQUFBQUE7QUFBQUE7QUFBQUE7QUFBQUE7QUFBQUE7QUFBQUEiLCJmaWxlIjoiZ2hlcmtpbi5mZWF0dXJlIiwic291cmNlc0NvbnRlbnQiOlsiVGVzdCJdfQ==`,
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'nomap.spec.js' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								throw  new  Error ( 'should not load nomap.spec.js' ) ; ` ,
  
						 
					
						
							
								
									
										
										
										
											2023-03-03 07:49:19 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ,  { } ,  { } ,  {  additionalArgs :  [ 'gherkin.feature' ]  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 19:49:01 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . passed ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'spec.js' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'another.feature.js' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'should not load' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-03 07:49:19 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'gherkin.feature:1' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2023-05-01 14:54:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'should not hang on worker error in test file' ,  async  ( {  runInlineTest  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  await  runInlineTest ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'example.spec.js' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      if  ( process . env . TEST_WORKER_INDEX ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process . exit ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'test 1' ,  async  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'test 2' ,  async  ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ,  {  'timeout' :  3000  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . exitCode ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . results [ 0 ] . status ) . toBe ( 'failed' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . results [ 0 ] . error . message ) . toContain ( 'Internal error: worker process exited unexpectedly' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . results [ 1 ] . status ) . toBe ( 'skipped' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
											
												fix(sigint): make sure we do not add handler twice (#24413)
In the following scenario, we were adding SIGINT handler twice, but
removing it just once:
- Task runner starts testing, creates SigIntWatcher, installs SIGINT
handler.
- Press Ctrl+C, task runner interrupts, disarms SigIntWatcher, SIGINT
handler is not removed due to 1000ms cooldown.
- Task runner starts cleanup, creates SigIntWatcher, installs another
SIGINT handler.
- Cleanup finishes, SigIntWatcher disarms, could remove or not remove
SIGINT handler based on timing (same 1000ms cooldown). In any case, we
have one or two SIGINT handlers still on.
- HTML reporter hangs in onExit, while we still have SIGINT handler up,
so Ctrl+C does not exit.
Regressed in #24265.
											 
										 
										
											2023-07-25 18:35:38 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'fast double SIGINT should be ignored' ,  async  ( {  interactWithTestRunner  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  test . skip ( process . platform  ===  'win32' ,  'No sending SIGINT on Windows' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  testProcess  =  await  interactWithTestRunner ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'playwright.config.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      export  default  {  globalTeardown :  './globalTeardown.ts'  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'globalTeardown.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      export  default  async  function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( 'teardown1' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  new  Promise ( f  = >  setTimeout ( f ,  2000 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( 'teardown2' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'interrupted' ,  async  ( {  } )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '\\n%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  new  Promise ( ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  testProcess . waitForOutput ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  // Send SIGINT twice in quick succession.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  {  exitCode  }  =  await  testProcess . exited ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( exitCode ) . toBe ( 130 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  parseTestRunnerOutput ( testProcess . output ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . interrupted ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'teardown1' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'teardown2' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'slow double SIGINT should be respected' ,  async  ( {  interactWithTestRunner  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  test . skip ( process . platform  ===  'win32' ,  'No sending SIGINT on Windows' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  testProcess  =  await  interactWithTestRunner ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'playwright.config.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      export  default  {  globalTeardown :  './globalTeardown.ts'  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'globalTeardown.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      export  default  async  function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( 'teardown1' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  new  Promise ( f  = >  setTimeout ( f ,  1000000 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'interrupted' ,  async  ( {  } )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '\\n%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  new  Promise ( ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  testProcess . waitForOutput ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  new  Promise ( f  = >  setTimeout ( f ,  2000 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  {  exitCode  }  =  await  testProcess . exited ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( exitCode ) . toBe ( 130 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  parseTestRunnerOutput ( testProcess . output ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . interrupted ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'teardown1' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( 'slow double SIGINT should be respected in reporter.onExit' ,  async  ( {  interactWithTestRunner  } )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  test . skip ( process . platform  ===  'win32' ,  'No sending SIGINT on Windows' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  testProcess  =  await  interactWithTestRunner ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'playwright.config.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      export  default  {  reporter :  './reporter'  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'reporter.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      export  default  class  MyReporter  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        onStdOut ( chunk )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          process . stdout . write ( chunk ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        async  onExit() { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          // This emulates html reporter, without opening a tab in the default browser.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( 'MyReporter.onExit started' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          await  new  Promise ( f  = >  setTimeout ( f ,  100000 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          console . log ( 'MyReporter.onExit finished' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'a.spec.ts' :  ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      import  {  test ,  expect  }  from  '@playwright/test' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      test ( 'interrupted' ,  async  ( {  } )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( '\\n%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  new  Promise ( ( )  = >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ` ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ,  {  reporter :  ''  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  testProcess . waitForOutput ( '%%SEND-SIGINT%%' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  new  Promise ( f  = >  setTimeout ( f ,  2000 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  testProcess . waitForOutput ( 'MyReporter.onExit started' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  process . kill ( testProcess . process . pid ! ,  'SIGINT' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  {  exitCode ,  signal  }  =  await  testProcess . exited ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( exitCode ) . toBe ( null ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( signal ) . toBe ( 'SIGINT' ) ;   // Default handler should report the signal.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  result  =  parseTestRunnerOutput ( testProcess . output ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . toContain ( 'MyReporter.onExit started' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( result . output ) . not . toContain ( 'MyReporter.onExit finished' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;