@@ -15,46 +15,74 @@ afterEach(() => rm(stateFile, { force: true }));
1515
1616const expectedStateFile = [
1717 {
18- 'test/fixtures/test-runner/rerun.js:17:3' : { passed_on_attempt : 0 , name : 'ambiguous (expectedAttempts=0)' } ,
1918 'test/fixtures/test-runner/rerun.js:9:1' : { passed_on_attempt : 0 , name : 'ok' } ,
19+ 'test/fixtures/test-runner/rerun.js:17:3' : { passed_on_attempt : 0 , name : 'ambiguous (expectedAttempts=0)' } ,
20+ 'test/fixtures/test-runner/rerun.js:30:16' : { passed_on_attempt : 0 , name : '2 levels deep' } ,
21+ 'test/fixtures/test-runner/rerun.js:29:13' : { passed_on_attempt : 0 , name : 'nested' } ,
22+ 'test/fixtures/test-runner/rerun.js:35:13' : { passed_on_attempt : 0 , name : 'ok' } ,
23+ 'test/fixtures/test-runner/rerun.js:39:1' : { passed_on_attempt : 0 , name : 'nested ambiguous (expectedAttempts=0)' } ,
24+ 'test/fixtures/test-runner/rerun.js:30:16:(1)' : { passed_on_attempt : 0 , name : '2 levels deep' } ,
25+ 'test/fixtures/test-runner/rerun.js:35:13:(1)' : { passed_on_attempt : 0 , name : 'ok' } ,
2026 } ,
2127 {
28+ 'test/fixtures/test-runner/rerun.js:9:1' : { passed_on_attempt : 0 , name : 'ok' } ,
2229 'test/fixtures/test-runner/rerun.js:17:3' : { passed_on_attempt : 0 , name : 'ambiguous (expectedAttempts=0)' } ,
2330 'test/fixtures/test-runner/rerun.js:17:3:(1)' : { passed_on_attempt : 1 , name : 'ambiguous (expectedAttempts=1)' } ,
24- 'test/fixtures/test-runner/rerun.js:9:1' : { passed_on_attempt : 0 , name : 'ok' } ,
31+ 'test/fixtures/test-runner/rerun.js:30:16' : { passed_on_attempt : 0 , name : '2 levels deep' } ,
32+ 'test/fixtures/test-runner/rerun.js:29:13' : { passed_on_attempt : 0 , name : 'nested' } ,
33+ 'test/fixtures/test-runner/rerun.js:35:13' : { passed_on_attempt : 0 , name : 'ok' } ,
34+ 'test/fixtures/test-runner/rerun.js:39:1' : { passed_on_attempt : 0 , name : 'nested ambiguous (expectedAttempts=0)' } ,
35+ 'test/fixtures/test-runner/rerun.js:30:16:(1)' : { passed_on_attempt : 0 , name : '2 levels deep' } ,
36+ 'test/fixtures/test-runner/rerun.js:35:13:(1)' : { passed_on_attempt : 0 , name : 'ok' } ,
2537 } ,
2638 {
39+ 'test/fixtures/test-runner/rerun.js:3:1' : { passed_on_attempt : 2 , name : 'should fail on first two attempts' } ,
40+ 'test/fixtures/test-runner/rerun.js:9:1' : { passed_on_attempt : 0 , name : 'ok' } ,
2741 'test/fixtures/test-runner/rerun.js:17:3' : { passed_on_attempt : 0 , name : 'ambiguous (expectedAttempts=0)' } ,
2842 'test/fixtures/test-runner/rerun.js:17:3:(1)' : { passed_on_attempt : 1 , name : 'ambiguous (expectedAttempts=1)' } ,
29- 'test/fixtures/test-runner/rerun.js:9:1' : { passed_on_attempt : 0 , name : 'ok' } ,
30- 'test/fixtures/test-runner/rerun.js:3:1' : { passed_on_attempt : 2 , name : 'should fail on first two attempts' } ,
43+ 'test/fixtures/test-runner/rerun.js:30:16' : { passed_on_attempt : 0 , name : '2 levels deep' } ,
44+ 'test/fixtures/test-runner/rerun.js:29:13' : { passed_on_attempt : 0 , name : 'nested' } ,
45+ 'test/fixtures/test-runner/rerun.js:35:13' : { passed_on_attempt : 0 , name : 'ok' } ,
46+ 'test/fixtures/test-runner/rerun.js:39:1' : { passed_on_attempt : 0 , name : 'nested ambiguous (expectedAttempts=0)' } ,
47+ 'test/fixtures/test-runner/rerun.js:29:13:(1)' : { passed_on_attempt : 2 , name : 'nested' } ,
48+ 'test/fixtures/test-runner/rerun.js:30:16:(1)' : { passed_on_attempt : 0 , name : '2 levels deep' } ,
49+ 'test/fixtures/test-runner/rerun.js:35:13:(1)' : { passed_on_attempt : 0 , name : 'ok' } ,
50+ 'test/fixtures/test-runner/rerun.js:40:1' : { passed_on_attempt : 2 , name : 'nested ambiguous (expectedAttempts=1)' } ,
3151 } ,
3252] ;
3353
34- const getStateFile = async ( ) => JSON . parse ( ( await readFile ( stateFile , 'utf8' ) ) . replaceAll ( '\\\\' , '/' ) ) ;
54+ const getStateFile = async ( ) => {
55+ const res = JSON . parse ( ( await readFile ( stateFile , 'utf8' ) ) . replaceAll ( '\\\\' , '/' ) ) ;
56+ res . forEach ( ( entry ) => {
57+ for ( const item in entry ) {
58+ delete entry [ item ] . children ;
59+ }
60+ } ) ;
61+ return res ;
62+ } ;
3563
3664test ( 'test should pass on third rerun' , async ( ) => {
3765 const args = [ '--test-rerun-failures' , stateFile , fixture ] ;
3866
3967 let { code, stdout, signal } = await common . spawnPromisified ( process . execPath , args ) ;
4068 assert . strictEqual ( code , 1 ) ;
4169 assert . strictEqual ( signal , null ) ;
42- assert . match ( stdout , / p a s s 2 / ) ;
43- assert . match ( stdout , / f a i l 2 / ) ;
70+ assert . match ( stdout , / p a s s 8 / ) ;
71+ assert . match ( stdout , / f a i l 4 / ) ;
4472 assert . deepStrictEqual ( await getStateFile ( ) , expectedStateFile . slice ( 0 , 1 ) ) ;
4573
4674 ( { code, stdout, signal } = await common . spawnPromisified ( process . execPath , args ) ) ;
4775 assert . strictEqual ( code , 1 ) ;
4876 assert . strictEqual ( signal , null ) ;
49- assert . match ( stdout , / p a s s 3 / ) ;
50- assert . match ( stdout , / f a i l 1 / ) ;
77+ assert . match ( stdout , / p a s s 9 / ) ;
78+ assert . match ( stdout , / f a i l 3 / ) ;
5179 assert . deepStrictEqual ( await getStateFile ( ) , expectedStateFile . slice ( 0 , 2 ) ) ;
5280
5381
5482 ( { code, stdout, signal } = await common . spawnPromisified ( process . execPath , args ) ) ;
5583 assert . strictEqual ( code , 0 ) ;
5684 assert . strictEqual ( signal , null ) ;
57- assert . match ( stdout , / p a s s 4 / ) ;
85+ assert . match ( stdout , / p a s s 1 2 / ) ;
5886 assert . match ( stdout , / f a i l 0 / ) ;
5987 assert . deepStrictEqual ( await getStateFile ( ) , expectedStateFile ) ;
6088} ) ;
@@ -65,30 +93,30 @@ test('test should pass on third rerun with `--test`', async () => {
6593 let { code, stdout, signal } = await common . spawnPromisified ( process . execPath , args ) ;
6694 assert . strictEqual ( code , 1 ) ;
6795 assert . strictEqual ( signal , null ) ;
68- assert . match ( stdout , / p a s s 2 / ) ;
69- assert . match ( stdout , / f a i l 2 / ) ;
96+ assert . match ( stdout , / p a s s 8 / ) ;
97+ assert . match ( stdout , / f a i l 4 / ) ;
7098 assert . deepStrictEqual ( await getStateFile ( ) , expectedStateFile . slice ( 0 , 1 ) ) ;
7199
72100 ( { code, stdout, signal } = await common . spawnPromisified ( process . execPath , args ) ) ;
73101 assert . strictEqual ( code , 1 ) ;
74102 assert . strictEqual ( signal , null ) ;
75- assert . match ( stdout , / p a s s 3 / ) ;
76- assert . match ( stdout , / f a i l 1 / ) ;
103+ assert . match ( stdout , / p a s s 9 / ) ;
104+ assert . match ( stdout , / f a i l 3 / ) ;
77105 assert . deepStrictEqual ( await getStateFile ( ) , expectedStateFile . slice ( 0 , 2 ) ) ;
78106
79107
80108 ( { code, stdout, signal } = await common . spawnPromisified ( process . execPath , args ) ) ;
81109 assert . strictEqual ( code , 0 ) ;
82110 assert . strictEqual ( signal , null ) ;
83- assert . match ( stdout , / p a s s 4 / ) ;
111+ assert . match ( stdout , / p a s s 1 2 / ) ;
84112 assert . match ( stdout , / f a i l 0 / ) ;
85113 assert . deepStrictEqual ( await getStateFile ( ) , expectedStateFile ) ;
86114} ) ;
87115
88116test ( 'using `run` api' , async ( ) => {
89117 let stream = run ( { files : [ fixture ] , rerunFailuresFilePath : stateFile } ) ;
90- stream . on ( 'test:pass' , common . mustCall ( 2 ) ) ;
91- stream . on ( 'test:fail' , common . mustCall ( 2 ) ) ;
118+ stream . on ( 'test:pass' , common . mustCall ( 8 ) ) ;
119+ stream . on ( 'test:fail' , common . mustCall ( 4 ) ) ;
92120
93121 // eslint-disable-next-line no-unused-vars
94122 for await ( const _ of stream ) ;
@@ -97,8 +125,8 @@ test('using `run` api', async () => {
97125
98126
99127 stream = run ( { files : [ fixture ] , rerunFailuresFilePath : stateFile } ) ;
100- stream . on ( 'test:pass' , common . mustCall ( 3 ) ) ;
101- stream . on ( 'test:fail' , common . mustCall ( 1 ) ) ;
128+ stream . on ( 'test:pass' , common . mustCall ( 9 ) ) ;
129+ stream . on ( 'test:fail' , common . mustCall ( 3 ) ) ;
102130
103131 // eslint-disable-next-line no-unused-vars
104132 for await ( const _ of stream ) ;
@@ -107,7 +135,7 @@ test('using `run` api', async () => {
107135
108136
109137 stream = run ( { files : [ fixture ] , rerunFailuresFilePath : stateFile } ) ;
110- stream . on ( 'test:pass' , common . mustCall ( 4 ) ) ;
138+ stream . on ( 'test:pass' , common . mustCall ( 12 ) ) ;
111139 stream . on ( 'test:fail' , common . mustNotCall ( ) ) ;
112140
113141 // eslint-disable-next-line no-unused-vars
0 commit comments