@@ -443,9 +443,8 @@ describe('class MongoLogger', async function () {
443443 const log : Log = { t : new Date ( ) , c : 'command' , s : 'error' } ;
444444 options . logDestination . write ( log ) ;
445445
446- expect ( stderrStub . write ) . to . have . been . calledOnceWith (
447- inspect ( log , { breakLength : Infinity , compact : true } )
448- ) ;
446+ const logLine = inspect ( log , { breakLength : Infinity , compact : true } ) ;
447+ expect ( stderrStub . write ) . to . have . been . calledOnceWith ( `${ logLine } \n` ) ;
449448 } ) ;
450449 }
451450 }
@@ -465,9 +464,8 @@ describe('class MongoLogger', async function () {
465464 const log : Log = { t : new Date ( ) , c : 'command' , s : 'error' } ;
466465 options . logDestination . write ( log ) ;
467466
468- expect ( stderrStub . write ) . to . have . been . calledOnceWith (
469- inspect ( log , { breakLength : Infinity , compact : true } )
470- ) ;
467+ const logLine = inspect ( log , { breakLength : Infinity , compact : true } ) ;
468+ expect ( stderrStub . write ) . to . have . been . calledOnceWith ( `${ logLine } \n` ) ;
471469 } ) ;
472470 }
473471 }
@@ -512,9 +510,8 @@ describe('class MongoLogger', async function () {
512510 const log : Log = { t : new Date ( ) , c : 'command' , s : 'error' } ;
513511 options . logDestination . write ( log ) ;
514512
515- expect ( stderrStub . write ) . to . have . been . calledOnceWith (
516- inspect ( log , { breakLength : Infinity , compact : true } )
517- ) ;
513+ const logLine = inspect ( log , { breakLength : Infinity , compact : true } ) ;
514+ expect ( stderrStub . write ) . to . have . been . calledOnceWith ( `${ logLine } \n` ) ;
518515 } ) ;
519516 }
520517 }
@@ -536,9 +533,8 @@ describe('class MongoLogger', async function () {
536533 const log : Log = { t : new Date ( ) , c : 'command' , s : 'error' } ;
537534 options . logDestination . write ( log ) ;
538535
539- expect ( stderrStub . write ) . to . have . been . calledOnceWith (
540- inspect ( log , { breakLength : Infinity , compact : true } )
541- ) ;
536+ const logLine = inspect ( log , { breakLength : Infinity , compact : true } ) ;
537+ expect ( stderrStub . write ) . to . have . been . calledOnceWith ( `${ logLine } \n` ) ;
542538 } ) ;
543539 }
544540 }
@@ -1399,9 +1395,8 @@ describe('class MongoLogger', async function () {
13991395 logger . debug ( 'client' , 'random message' ) ;
14001396 let stderrStubCall = stderrStub . write . getCall ( 0 ) . args [ 0 ] ;
14011397 stderrStubCall = stderrStubCall . slice ( stderrStubCall . search ( 'c:' ) ) ;
1402- expect ( stderrStubCall ) . to . equal (
1403- `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'This writable always throws' }`
1404- ) ;
1398+ const expectedLogLine1 = `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'This writable always throws' }` ;
1399+ expect ( stderrStubCall ) . to . equal ( `${ expectedLogLine1 } \n` ) ;
14051400
14061401 // logging is halted
14071402 logger . debug ( 'client' , 'random message 2' ) ;
@@ -1450,9 +1445,8 @@ describe('class MongoLogger', async function () {
14501445 // stderr now contains the error message
14511446 let stderrStubCall = stderrStub . write . getCall ( 0 ) . args [ 0 ] ;
14521447 stderrStubCall = stderrStubCall . slice ( stderrStubCall . search ( 'c:' ) ) ;
1453- expect ( stderrStubCall ) . to . equal (
1454- `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'This writable always throws, but only after at least 500ms' }`
1455- ) ;
1448+ const expectedLogLine1 = `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'This writable always throws, but only after at least 500ms' }` ;
1449+ expect ( stderrStubCall ) . to . equal ( `${ expectedLogLine1 } \n` ) ;
14561450
14571451 // no more logging in the future
14581452 logger . debug ( 'client' , 'random message 2' ) ;
@@ -1480,7 +1474,7 @@ describe('class MongoLogger', async function () {
14801474 let stderrStubCall = stderrStub . write . getCall ( 0 ) . args [ 0 ] ;
14811475 stderrStubCall = stderrStubCall . slice ( stderrStubCall . search ( 'c:' ) ) ;
14821476 expect ( stderrStubCall ) . to . equal (
1483- `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'I am stdout and do not work' }`
1477+ `c: 'client', s: 'error', message: 'User input for mongodbLogPath is now invalid. Logging is halted.', error: 'I am stdout and do not work' }\n `
14841478 ) ;
14851479
14861480 // logging is halted
0 commit comments