@@ -134,4 +134,25 @@ describe('node:test reporters', { concurrency: true }, () => {
134134 assert . strictEqual ( child . stdout . toString ( ) , '' ) ;
135135 assert . match ( child . stderr . toString ( ) , / E R R _ I N V A L I D _ A R G _ T Y P E / ) ;
136136 } ) ;
137+
138+ it ( 'should throw when reporter errors' , async ( ) => {
139+ const child = spawnSync ( process . execPath ,
140+ [ '--test' , '--test-reporter' , fixtures . fileURL ( 'test-runner/custom_reporters/throwing.js' ) ,
141+ fixtures . path ( 'test-runner/default-behavior/index.test.js' ) ] ) ;
142+ assert . strictEqual ( child . status , 7 ) ;
143+ assert . strictEqual ( child . signal , null ) ;
144+ assert . strictEqual ( child . stdout . toString ( ) , 'Going to throw an error\n' ) ;
145+ assert . match ( child . stderr . toString ( ) , / E r r o r : R e p o r t i n g e r r o r \r ? \n \s + a t c u s t o m R e p o r t e r / ) ;
146+ } ) ;
147+
148+ it ( 'should throw when reporter errors asynchronously' , async ( ) => {
149+ const child = spawnSync ( process . execPath ,
150+ [ '--test' , '--test-reporter' ,
151+ fixtures . fileURL ( 'test-runner/custom_reporters/throwing-async.js' ) ,
152+ fixtures . path ( 'test-runner/default-behavior/index.test.js' ) ] ) ;
153+ assert . strictEqual ( child . status , 7 ) ;
154+ assert . strictEqual ( child . signal , null ) ;
155+ assert . strictEqual ( child . stdout . toString ( ) , 'Going to throw an error\n' ) ;
156+ assert . match ( child . stderr . toString ( ) , / E m i t t e d ' e r r o r ' e v e n t o n D u p l e x i n s t a n c e / ) ;
157+ } ) ;
137158} ) ;
0 commit comments