@@ -61,7 +61,9 @@ describe('MongoshLoggingAndTelemetry', function () {
6161
6262 logger = new MongoLogWriter ( logId , `/tmp/${ logId } _log` , {
6363 write ( chunk : string , cb : ( ) => void ) {
64- logOutput . push ( JSON . parse ( chunk ) ) ;
64+ if ( chunk . trim ( ) ) {
65+ logOutput . push ( JSON . parse ( chunk ) ) ;
66+ }
6567 cb ( ) ;
6668 } ,
6769 end ( cb : ( ) => void ) {
@@ -70,8 +72,8 @@ describe('MongoshLoggingAndTelemetry', function () {
7072 } as Writable ) ;
7173 } ) ;
7274
73- afterEach ( function ( ) {
74- loggingAndTelemetry . detachLogger ( ) ;
75+ afterEach ( async function ( ) {
76+ await loggingAndTelemetry . detachLogger ( ) ;
7577 logger . destroy ( ) ;
7678 } ) ;
7779
@@ -82,9 +84,9 @@ describe('MongoshLoggingAndTelemetry', function () {
8284 ) ;
8385 } ) ;
8486
85- it ( 'does not throw when attaching and detaching loggers' , function ( ) {
87+ it ( 'does not throw when attaching and detaching loggers' , async function ( ) {
8688 loggingAndTelemetry . attachLogger ( logger ) ;
87- loggingAndTelemetry . detachLogger ( ) ;
89+ await loggingAndTelemetry . detachLogger ( ) ;
8890 expect ( ( ) => loggingAndTelemetry . attachLogger ( logger ) ) . does . not . throw ( ) ;
8991 } ) ;
9092
@@ -308,7 +310,7 @@ describe('MongoshLoggingAndTelemetry', function () {
308310 . setupTelemetryPromise ;
309311
310312 // Flush before it completes
311- loggingAndTelemetry . flush ( ) ;
313+ await loggingAndTelemetry . flush ( ) ;
312314
313315 // Emit an event that would trigger analytics
314316 bus . emit ( 'mongosh:new-user' , { userId, anonymousId : userId } ) ;
@@ -377,7 +379,7 @@ describe('MongoshLoggingAndTelemetry', function () {
377379 expect ( logOutput ) . to . have . lengthOf ( 0 ) ;
378380 expect ( analyticsOutput ) . to . have . lengthOf ( 0 ) ;
379381
380- loggingAndTelemetry . detachLogger ( ) ;
382+ await loggingAndTelemetry . detachLogger ( ) ;
381383
382384 // This event has both analytics and logging
383385 bus . emit ( 'mongosh:use' , { db : '' } ) ;
@@ -386,7 +388,7 @@ describe('MongoshLoggingAndTelemetry', function () {
386388 expect ( analyticsOutput ) . to . have . lengthOf ( 1 ) ;
387389 } ) ;
388390
389- it ( 'detaching logger applies to devtools-connect events' , function ( ) {
391+ it ( 'detaching logger applies to devtools-connect events' , async function ( ) {
390392 loggingAndTelemetry . attachLogger ( logger ) ;
391393
392394 bus . emit ( 'devtools-connect:connect-fail-early' ) ;
@@ -396,7 +398,7 @@ describe('MongoshLoggingAndTelemetry', function () {
396398 // No analytics event attached to this
397399 expect ( analyticsOutput ) . to . have . lengthOf ( 0 ) ;
398400
399- loggingAndTelemetry . detachLogger ( ) ;
401+ await loggingAndTelemetry . detachLogger ( ) ;
400402 bus . emit ( 'devtools-connect:connect-fail-early' ) ;
401403
402404 expect ( logOutput ) . to . have . lengthOf ( 2 ) ;
@@ -423,7 +425,7 @@ describe('MongoshLoggingAndTelemetry', function () {
423425 await ( loggingAndTelemetry as LoggingAndTelemetry ) . setupTelemetryPromise ;
424426 expect ( analyticsOutput ) . to . have . lengthOf ( 1 ) ;
425427
426- loggingAndTelemetry . detachLogger ( ) ;
428+ await loggingAndTelemetry . detachLogger ( ) ;
427429
428430 bus . emit ( 'mongosh:use' , { db : '' } ) ;
429431
@@ -446,7 +448,7 @@ describe('MongoshLoggingAndTelemetry', function () {
446448
447449 expect ( analyticsOutput ) . to . have . lengthOf ( 1 ) ;
448450
449- loggingAndTelemetry . detachLogger ( ) ;
451+ await loggingAndTelemetry . detachLogger ( ) ;
450452
451453 bus . emit ( 'mongosh:use' , { db : '' } ) ;
452454
0 commit comments