@@ -36,39 +36,39 @@ export type RunResult = {
3636} ;
3737
3838async function runTest ( reportFile : string , outputDir : string , filePath : string , params : any = { } ) : Promise < RunResult > {
39- const { output, status } = spawnSync ( 'node' , [
40- path . join ( __dirname , '..' , 'cli.js' ) ,
41- path . join ( __dirname , 'assets' , filePath ) ,
42- '--output=' + outputDir ,
43- '--reporter=dot,json' ,
44- ...Object . keys ( params ) . map ( key => `--${ key } =${ params [ key ] } ` )
45- ] , {
46- env : {
47- ...process . env ,
48- PW_OUTPUT_DIR : outputDir ,
49- PWRUNNER_JSON_REPORT : reportFile ,
50- }
51- } ) ;
52- const passed = ( / ( \d + ) p a s s e d / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
53- const failed = ( / ( \d + ) f a i l e d / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
54- const timedOut = ( / ( \d + ) t i m e d o u t / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
55- const expectedFlaky = ( / ( \d + ) e x p e c t e d f l a k y / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
56- const unexpectedFlaky = ( / ( \d + ) u n e x p e c t e d f l a k y / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
57- const skipped = ( / ( \d + ) s k i p p e d / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
58- const report = JSON . parse ( fs . readFileSync ( reportFile ) . toString ( ) ) ;
59- let outputStr = output . toString ( ) ;
60- outputStr = outputStr . substring ( 1 , outputStr . length - 1 ) ;
61- return {
62- exitCode : status ,
63- output : outputStr ,
64- passed : parseInt ( passed , 10 ) ,
65- failed : parseInt ( failed || '0' , 10 ) ,
66- timedOut : parseInt ( timedOut || '0' , 10 ) ,
67- expectedFlaky : parseInt ( expectedFlaky || '0' , 10 ) ,
68- unexpectedFlaky : parseInt ( unexpectedFlaky || '0' , 10 ) ,
69- skipped : parseInt ( skipped || '0' , 10 ) ,
70- report
71- } ;
39+ const { output, status } = spawnSync ( 'node' , [
40+ path . join ( __dirname , '..' , 'cli.js' ) ,
41+ path . join ( __dirname , 'assets' , filePath ) ,
42+ '--output=' + outputDir ,
43+ '--reporter=dot,json' ,
44+ ...Object . keys ( params ) . map ( key => `--${ key } =${ params [ key ] } ` )
45+ ] , {
46+ env : {
47+ ...process . env ,
48+ PW_OUTPUT_DIR : outputDir ,
49+ PWRUNNER_JSON_REPORT : reportFile ,
50+ }
51+ } ) ;
52+ const passed = ( / ( \d + ) p a s s e d / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
53+ const failed = ( / ( \d + ) f a i l e d / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
54+ const timedOut = ( / ( \d + ) t i m e d o u t / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
55+ const expectedFlaky = ( / ( \d + ) e x p e c t e d f l a k y / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
56+ const unexpectedFlaky = ( / ( \d + ) u n e x p e c t e d f l a k y / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
57+ const skipped = ( / ( \d + ) s k i p p e d / . exec ( output . toString ( ) ) || [ ] ) [ 1 ] ;
58+ const report = JSON . parse ( fs . readFileSync ( reportFile ) . toString ( ) ) ;
59+ let outputStr = output . toString ( ) ;
60+ outputStr = outputStr . substring ( 1 , outputStr . length - 1 ) ;
61+ return {
62+ exitCode : status ,
63+ output : outputStr ,
64+ passed : parseInt ( passed , 10 ) ,
65+ failed : parseInt ( failed || '0' , 10 ) ,
66+ timedOut : parseInt ( timedOut || '0' , 10 ) ,
67+ expectedFlaky : parseInt ( expectedFlaky || '0' , 10 ) ,
68+ unexpectedFlaky : parseInt ( unexpectedFlaky || '0' , 10 ) ,
69+ skipped : parseInt ( skipped || '0' , 10 ) ,
70+ report
71+ } ;
7272}
7373
7474declare global {
@@ -79,11 +79,11 @@ declare global {
7979}
8080
8181registerFixture ( 'outputDir' , async ( { } , testRun ) => {
82- await testRun ( path . join ( __dirname , 'test-results' , String ( parameters . parallelIndex ) ) ) ;
82+ await testRun ( path . join ( __dirname , 'test-results' , String ( parameters . parallelIndex ) ) ) ;
8383} ) ;
8484
8585registerFixture ( 'runTest' , async ( { outputDir } , testRun ) => {
86- const reportFile = path . join ( outputDir , `results-${ parameters . parallelIndex } .json` ) ;
87- await removeFolderAsync ( outputDir ) . catch ( e => { } ) ;
88- await testRun ( runTest . bind ( null , reportFile , outputDir ) ) ;
86+ const reportFile = path . join ( outputDir , `results-${ parameters . parallelIndex } .json` ) ;
87+ await removeFolderAsync ( outputDir ) . catch ( e => { } ) ;
88+ await testRun ( runTest . bind ( null , reportFile , outputDir ) ) ;
8989} ) ;
0 commit comments