@@ -135,4 +135,25 @@ describe('node:test reporters', { concurrency: true }, () => {
135
135
assert . strictEqual ( child . stdout . toString ( ) , '' ) ;
136
136
assert . match ( child . stderr . toString ( ) , / E R R _ I N V A L I D _ A R G _ T Y P E / ) ;
137
137
} ) ;
138
+
139
+ it ( 'should throw when reporter errors' , async ( ) => {
140
+ const child = spawnSync ( process . execPath ,
141
+ [ '--test' , '--test-reporter' , fixtures . fileURL ( 'test-runner/custom_reporters/throwing.js' ) ,
142
+ fixtures . path ( 'test-runner/default-behavior/index.test.js' ) ] ) ;
143
+ assert . strictEqual ( child . status , 7 ) ;
144
+ assert . strictEqual ( child . signal , null ) ;
145
+ assert . strictEqual ( child . stdout . toString ( ) , 'Going to throw an error\n' ) ;
146
+ 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 / ) ;
147
+ } ) ;
148
+
149
+ it ( 'should throw when reporter errors asynchronously' , async ( ) => {
150
+ const child = spawnSync ( process . execPath ,
151
+ [ '--test' , '--test-reporter' ,
152
+ fixtures . fileURL ( 'test-runner/custom_reporters/throwing-async.js' ) ,
153
+ fixtures . path ( 'test-runner/default-behavior/index.test.js' ) ] ) ;
154
+ assert . strictEqual ( child . status , 7 ) ;
155
+ assert . strictEqual ( child . signal , null ) ;
156
+ assert . strictEqual ( child . stdout . toString ( ) , 'Going to throw an error\n' ) ;
157
+ 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 / ) ;
158
+ } ) ;
138
159
} ) ;
0 commit comments