@@ -35,8 +35,8 @@ const {
3535
3636const { AsyncResource } = require ( 'async_hooks' ) ;
3737const { tracingChannel } = require ( 'diagnostics_channel' ) ;
38- const { relative, sep, resolve } = require ( 'path' ) ;
39- const { createWriteStream, readFileSync } = require ( 'fs' ) ;
38+ const { dirname , relative, sep, resolve } = require ( 'path' ) ;
39+ const { createWriteStream, mkdirSync , readFileSync } = require ( 'fs' ) ;
4040const { pathToFileURL } = require ( 'internal/url' ) ;
4141const { getOptionValue } = require ( 'internal/options' ) ;
4242const { green, yellow, red, white, shouldColorize } = require ( 'internal/util/colors' ) ;
@@ -199,8 +199,11 @@ function parsePreviousRuns(rerunFailuresFilePath) {
199199
200200async function getReportersMap ( reporters , destinations ) {
201201 return SafePromiseAllReturnArrayLike ( reporters , async ( name , i ) => {
202- const destination = kBuiltinDestinations . get ( destinations [ i ] ) ??
203- createWriteStream ( destinations [ i ] , { __proto__ : null , flush : true } ) ;
202+ const destinationPath = destinations [ i ] ;
203+ const destination = kBuiltinDestinations . get ( destinationPath ) ?? (
204+ mkdirSync ( dirname ( destinationPath ) , { recursive : true } ) ,
205+ createWriteStream ( destinationPath , { __proto__ : null , flush : true } )
206+ ) ;
204207
205208 // Load the test reporter passed to --test-reporter
206209 let reporter = tryBuiltinReporter ( name ) ;
0 commit comments