@@ -57,7 +57,8 @@ const {
5757 getOSDetailsFromSystem,
5858 findGitConfig,
5959 getFileSeparatorData,
60- setCrashReportingConfigFromReporter
60+ setCrashReportingConfigFromReporter,
61+ debugOnConsole
6162} = require ( '../helper/helper' ) ;
6263
6364const { consoleHolder } = require ( '../helper/constants' ) ;
@@ -87,13 +88,15 @@ class MyReporter {
8788 } )
8889
8990 . on ( EVENT_HOOK_BEGIN , async ( hook ) => {
91+ debugOnConsole ( `[MOCHA EVENT] EVENT_HOOK_BEGIN` ) ;
9092 if ( this . testObservability == true ) {
9193 if ( ! hook . hookAnalyticsId ) {
9294 hook . hookAnalyticsId = uuidv4 ( ) ;
9395 } else if ( this . runStatusMarkedHash [ hook . hookAnalyticsId ] ) {
9496 delete this . runStatusMarkedHash [ hook . hookAnalyticsId ] ;
9597 hook . hookAnalyticsId = uuidv4 ( ) ;
9698 }
99+ debugOnConsole ( `[MOCHA EVENT] EVENT_HOOK_BEGIN for uuid: ${ hook . hookAnalyticsId } ` ) ;
97100 hook . hook_started_at = ( new Date ( ) ) . toISOString ( ) ;
98101 hook . started_at = ( new Date ( ) ) . toISOString ( ) ;
99102 this . current_hook = hook ;
@@ -102,6 +105,7 @@ class MyReporter {
102105 } )
103106
104107 . on ( EVENT_HOOK_END , async ( hook ) => {
108+ debugOnConsole ( `[MOCHA EVENT] EVENT_HOOK_END` ) ;
105109 if ( this . testObservability == true ) {
106110 if ( ! this . runStatusMarkedHash [ hook . hookAnalyticsId ] ) {
107111 if ( ! hook . hookAnalyticsId ) {
@@ -114,6 +118,9 @@ class MyReporter {
114118
115119 // Remove hooks added at hook start
116120 delete this . hooksStarted [ hook . hookAnalyticsId ] ;
121+
122+ debugOnConsole ( `[MOCHA EVENT] EVENT_HOOK_END for uuid: ${ hook . hookAnalyticsId } ` ) ;
123+
117124 await this . sendTestRunEvent ( hook , undefined , false , "HookRunFinished" ) ;
118125 }
119126 }
@@ -123,7 +130,9 @@ class MyReporter {
123130 } )
124131
125132 . on ( EVENT_TEST_PASS , async ( test ) => {
133+ debugOnConsole ( `[MOCHA EVENT] EVENT_TEST_PASS` ) ;
126134 if ( this . testObservability == true ) {
135+ debugOnConsole ( `[MOCHA EVENT] EVENT_TEST_PASS for uuid: ${ test . testAnalyticsId } ` ) ;
127136 if ( ! this . runStatusMarkedHash [ test . testAnalyticsId ] ) {
128137 if ( test . testAnalyticsId ) this . runStatusMarkedHash [ test . testAnalyticsId ] = true ;
129138 await this . sendTestRunEvent ( test ) ;
@@ -132,7 +141,9 @@ class MyReporter {
132141 } )
133142
134143 . on ( EVENT_TEST_FAIL , async ( test , err ) => {
144+ debugOnConsole ( `[MOCHA EVENT] EVENT_TEST_FAIL` ) ;
135145 if ( this . testObservability == true ) {
146+ debugOnConsole ( `[MOCHA EVENT] EVENT_TEST_FAIL for uuid: ${ test . testAnalyticsId } ` ) ;
136147 if ( ( test . testAnalyticsId && ! this . runStatusMarkedHash [ test . testAnalyticsId ] ) || ( test . hookAnalyticsId && ! this . runStatusMarkedHash [ test . hookAnalyticsId ] ) ) {
137148 if ( test . testAnalyticsId ) {
138149 this . runStatusMarkedHash [ test . testAnalyticsId ] = true ;
@@ -146,8 +157,10 @@ class MyReporter {
146157 } )
147158
148159 . on ( EVENT_TEST_PENDING , async ( test ) => {
160+ debugOnConsole ( `[MOCHA EVENT] EVENT_TEST_PENDING` ) ;
149161 if ( this . testObservability == true ) {
150162 if ( ! test . testAnalyticsId ) test . testAnalyticsId = uuidv4 ( ) ;
163+ debugOnConsole ( `[MOCHA EVENT] EVENT_TEST_PENDING for uuid: ${ test . testAnalyticsId } ` ) ;
151164 if ( ! this . runStatusMarkedHash [ test . testAnalyticsId ] ) {
152165 this . runStatusMarkedHash [ test . testAnalyticsId ] = true ;
153166 await this . sendTestRunEvent ( test , undefined , false , "TestRunSkipped" ) ;
@@ -156,13 +169,17 @@ class MyReporter {
156169 } )
157170
158171 . on ( EVENT_TEST_BEGIN , async ( test ) => {
172+ debugOnConsole ( `[MOCHA EVENT] EVENT_TEST_BEGIN` ) ;
173+ debugOnConsole ( `[MOCHA EVENT] EVENT_TEST_BEGIN for uuid: ${ test . testAnalyticsId } ` ) ;
159174 if ( this . runStatusMarkedHash [ test . testAnalyticsId ] ) return ;
160175 if ( this . testObservability == true ) {
161176 await this . testStarted ( test ) ;
162177 }
163178 } )
164179
165180 . on ( EVENT_TEST_END , async ( test ) => {
181+ debugOnConsole ( `[MOCHA EVENT] EVENT_TEST_END` ) ;
182+ debugOnConsole ( `[MOCHA EVENT] EVENT_TEST_BEGIN for uuid: ${ test . testAnalyticsId } ` ) ;
166183 if ( this . runStatusMarkedHash [ test . testAnalyticsId ] ) return ;
167184 if ( this . testObservability == true ) {
168185 if ( ! this . runStatusMarkedHash [ test . testAnalyticsId ] ) {
@@ -174,10 +191,12 @@ class MyReporter {
174191
175192 . once ( EVENT_RUN_END , async ( ) => {
176193 try {
194+ debugOnConsole ( `[MOCHA EVENT] EVENT_RUN_END` ) ;
177195 if ( this . testObservability == true ) {
178196 const hookSkippedTests = getHookSkippedTests ( this . runner . suite ) ;
179197 for ( const test of hookSkippedTests ) {
180198 if ( ! test . testAnalyticsId ) test . testAnalyticsId = uuidv4 ( ) ;
199+ debugOnConsole ( `[MOCHA EVENT] EVENT_RUN_END TestRunSkipped for uuid: ${ test . testAnalyticsId } ` ) ;
181200 await this . sendTestRunEvent ( test , undefined , false , "TestRunSkipped" ) ;
182201 }
183202 }
@@ -318,6 +337,8 @@ class MyReporter {
318337 }
319338 } ;
320339
340+ debugOnConsole ( `${ eventType } for uuid: ${ testData . uuid } ` ) ;
341+
321342 if ( eventType . match ( / T e s t R u n F i n i s h e d / ) || eventType . match ( / T e s t R u n S k i p p e d / ) ) {
322343 testData [ 'meta' ] . steps = JSON . parse ( JSON . stringify ( this . currentTestCucumberSteps ) ) ;
323344 this . currentTestCucumberSteps = [ ] ;
@@ -377,6 +398,7 @@ class MyReporter {
377398 mapTestHooks ( test ) ;
378399 }
379400 } catch ( e ) {
401+ debugOnConsole ( `Exception in processing hook data for event ${ eventType } with error : ${ e } ` ) ;
380402 debug ( `Exception in processing hook data for event ${ eventType } with error : ${ e } ` , true , e ) ;
381403 }
382404
@@ -473,6 +495,7 @@ class MyReporter {
473495 this . hooksStarted = { } ;
474496 }
475497 } catch ( error ) {
498+ debugOnConsole ( `Exception in populating test data for event ${ eventType } with error : ${ error } ` ) ;
476499 debug ( `Exception in populating test data for event ${ eventType } with error : ${ error } ` , true , error ) ;
477500 }
478501 }
0 commit comments