@@ -345,7 +345,8 @@ describe('CodeceptJS Workers Runner', function () {
345345 if ( ! semver . satisfies ( process . version , '>=11.7.0' ) ) this . skip ( 'not for node version' )
346346 // Run regular workers mode first to get baseline counts
347347 exec ( `${ codecept_run } 2` , ( err , stdout ) => {
348- const regularStats = stdout . match ( / ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? (?: , \s + ( \d + ) f a i l e d H o o k s ) ? / )
348+ // Match only the final summary line (starts with spaces, not [Worker])
349+ const regularStats = stdout . match ( / ^ \s { 2 } ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? (?: , \s + ( \d + ) f a i l e d H o o k s ) ? / m)
349350 if ( ! regularStats ) return done ( new Error ( 'Could not parse regular mode statistics' ) )
350351
351352 const expectedPassed = parseInt ( regularStats [ 2 ] )
@@ -357,8 +358,8 @@ describe('CodeceptJS Workers Runner', function () {
357358 expect ( stdout2 ) . toContain ( 'CodeceptJS' )
358359 expect ( stdout2 ) . toContain ( 'Running tests in 2 workers' )
359360
360- // Extract pool mode statistics
361- const poolStats = stdout2 . match ( / ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? (?: , \s + ( \d + ) f a i l e d H o o k s ) ? / )
361+ // Match only the final summary line
362+ const poolStats = stdout2 . match ( / ^ \s { 2 } ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? (?: , \s + ( \d + ) f a i l e d H o o k s ) ? / m )
362363 expect ( poolStats ) . toBeTruthy ( )
363364
364365 const actualPassed = parseInt ( poolStats [ 2 ] )
@@ -381,15 +382,17 @@ describe('CodeceptJS Workers Runner', function () {
381382 if ( ! semver . satisfies ( process . version , '>=11.7.0' ) ) this . skip ( 'not for node version' )
382383 // Run regular workers mode with grep first
383384 exec ( `${ codecept_run } 2 --grep "grep"` , ( err , stdout ) => {
384- const regularStats = stdout . match ( / ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / )
385+ // Match only the final summary line (starts with spaces, not [Worker])
386+ const regularStats = stdout . match ( / ^ \s { 2 } ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / m)
385387 if ( ! regularStats ) return done ( new Error ( 'Could not parse regular mode grep statistics' ) )
386388
387389 const expectedPassed = parseInt ( regularStats [ 2 ] )
388390 const expectedFailed = parseInt ( regularStats [ 3 ] || '0' )
389391
390392 // Now run pool mode with grep and compare
391393 exec ( `${ codecept_run } 2 --by pool --grep "grep"` , ( err2 , stdout2 ) => {
392- const poolStats = stdout2 . match ( / ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / )
394+ // Match only the final summary line
395+ const poolStats = stdout2 . match ( / ^ \s { 2 } ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / m)
393396 expect ( poolStats ) . toBeTruthy ( )
394397
395398 const actualPassed = parseInt ( poolStats [ 2 ] )
@@ -408,15 +411,17 @@ describe('CodeceptJS Workers Runner', function () {
408411 if ( ! semver . satisfies ( process . version , '>=11.7.0' ) ) this . skip ( 'not for node version' )
409412 // Run pool mode with 1 worker
410413 exec ( `${ codecept_run } 1 --by pool --grep "grep"` , ( err , stdout ) => {
411- const singleStats = stdout . match ( / ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / )
414+ // Match only the final summary line (starts with spaces, not [Worker])
415+ const singleStats = stdout . match ( / ^ \s { 2 } ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / m)
412416 if ( ! singleStats ) return done ( new Error ( 'Could not parse single worker statistics' ) )
413417
414418 const singlePassed = parseInt ( singleStats [ 2 ] )
415419 const singleFailed = parseInt ( singleStats [ 3 ] || '0' )
416420
417421 // Run pool mode with multiple workers
418422 exec ( `${ codecept_run } 3 --by pool --grep "grep"` , ( err2 , stdout2 ) => {
419- const multiStats = stdout2 . match ( / ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / )
423+ // Match only the final summary line
424+ const multiStats = stdout2 . match ( / ^ \s { 2 } ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / m)
420425 expect ( multiStats ) . toBeTruthy ( )
421426
422427 const multiPassed = parseInt ( multiStats [ 2 ] )
@@ -462,8 +467,8 @@ describe('CodeceptJS Workers Runner', function () {
462467 expect ( stdout ) . toContain ( 'CodeceptJS' )
463468 expect ( stdout ) . toContain ( 'Running tests in 2 workers' )
464469
465- // Should have some passing and some failing tests
466- const stats = stdout . match ( / ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? (?: , \s + ( \d + ) f a i l e d H o o k s ) ? / )
470+ // Match only the final summary line (starts with spaces, not [Worker])
471+ const stats = stdout . match ( / ^ \s { 2 } ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? (?: , \s + ( \d + ) f a i l e d H o o k s ) ? / m )
467472 expect ( stats ) . toBeTruthy ( )
468473
469474 const passed = parseInt ( stats [ 2 ] )
@@ -482,15 +487,17 @@ describe('CodeceptJS Workers Runner', function () {
482487 if ( ! semver . satisfies ( process . version , '>=11.7.0' ) ) this . skip ( 'not for node version' )
483488 // Run pool mode first time
484489 exec ( `${ codecept_run } 2 --by pool --grep "grep"` , ( err , stdout ) => {
485- const firstStats = stdout . match ( / ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / )
490+ // Match only the final summary line (starts with spaces, not [Worker])
491+ const firstStats = stdout . match ( / ^ \s { 2 } ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / m)
486492 if ( ! firstStats ) return done ( new Error ( 'Could not parse first run statistics' ) )
487493
488494 const firstPassed = parseInt ( firstStats [ 2 ] )
489495 const firstFailed = parseInt ( firstStats [ 3 ] || '0' )
490496
491497 // Run pool mode second time
492498 exec ( `${ codecept_run } 2 --by pool --grep "grep"` , ( err2 , stdout2 ) => {
493- const secondStats = stdout2 . match ( / ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / )
499+ // Match only the final summary line
500+ const secondStats = stdout2 . match ( / ^ \s { 2 } ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / m)
494501 expect ( secondStats ) . toBeTruthy ( )
495502
496503 const secondPassed = parseInt ( secondStats [ 2 ] )
@@ -512,7 +519,8 @@ describe('CodeceptJS Workers Runner', function () {
512519 expect ( stdout ) . toContain ( 'CodeceptJS' )
513520 expect ( stdout ) . toContain ( 'Running tests in 8 workers' )
514521
515- const stats = stdout . match ( / ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / )
522+ // Match only the final summary line (starts with spaces, not [Worker])
523+ const stats = stdout . match ( / ^ \s { 2 } ( F A I L | O K ) \s + \| \s + ( \d + ) p a s s e d (?: , \s + ( \d + ) f a i l e d ) ? / m)
516524 expect ( stats ) . toBeTruthy ( )
517525
518526 const passed = parseInt ( stats [ 2 ] )
0 commit comments