File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed
Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change 11import * as util from 'node:util' ;
2+ import * as types from 'node:util/types' ;
23
34import { expect } from 'chai' ;
45import { type Context } from 'mocha' ;
@@ -9,6 +10,7 @@ import * as url from 'url';
910import {
1011 type AuthMechanism ,
1112 HostAddress ,
13+ Long ,
1214 MongoClient ,
1315 type MongoClientOptions ,
1416 ObjectId ,
@@ -466,13 +468,23 @@ export class TestConfiguration {
466468 afterEachLogging ( ctx : Context ) {
467469 if ( this . loggingEnabled && ctx . currentTest . state === 'failed' ) {
468470 for ( const log of this . logs ) {
469- const logLine = util . inspect ( log , {
470- compact : true ,
471- breakLength : Infinity ,
472- colors : true ,
473- depth : 1000
474- } ) ;
475- console . error ( logLine ) ;
471+ console . error (
472+ JSON . stringify (
473+ log ,
474+ function ( _ , value ) {
475+ if ( types . isMap ( value ) ) return { Map : Array . from ( value . entries ( ) ) } ;
476+ if ( types . isSet ( value ) ) return { Set : Array . from ( value . values ( ) ) } ;
477+ if ( types . isNativeError ( value ) ) return { [ value . name ] : util . inspect ( value ) } ;
478+ if ( typeof value === 'bigint' ) return new Long ( value ) . toExtendedJSON ( ) ;
479+ if ( typeof value === 'symbol' ) return `Symbol(${ value . description } )` ;
480+ if ( Buffer . isBuffer ( value ) )
481+ return { [ value . constructor . name ] : Buffer . prototype . base64Slice . call ( value ) } ;
482+ if ( value === undefined ) return { undefined : 'key was set but equal to undefined' } ;
483+ return value ;
484+ } ,
485+ 0
486+ )
487+ ) ;
476488 }
477489 }
478490 this . loggingEnabled = false ;
You can’t perform that action at this time.
0 commit comments