Skip to content

Commit 82b1c50

Browse files
committed
fix: beforeall duration
1 parent 023a85f commit 82b1c50

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bin/testObservability/reporter/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ class MyReporter {
147147

148148
.on(EVENT_TEST_PENDING, async (test) => {
149149
if(this.testObservability == true) {
150-
test.isSkipped = true;
151150
if(!test.testAnalyticsId) test.testAnalyticsId = uuidv4();
152151
if(!this.runStatusMarkedHash[test.testAnalyticsId]) {
153152
this.runStatusMarkedHash[test.testAnalyticsId] = true;
@@ -451,14 +450,20 @@ class MyReporter {
451450
// Send pending hook finsihed events for hook starts
452451
if (eventType === 'TestRunFinished') {
453452
Object.values(this.hooksStarted).forEach(async hookData => {
454-
hookData['hook_run'].finished_at = hookData['hook_run'].started_at;
455-
hookData['hook_run'].duration = 0;
453+
hookData['event_type'] = 'HookRunFinished';
456454
hookData['hook_run'].result = uploadData['test_run'].result;
457455
hookData['hook_run'].failure = uploadData['test_run'].failure;
458456
hookData['hook_run'].failure_type = uploadData['test_run'].failure_type;
459457
hookData['hook_run'].failure_reason = uploadData['test_run'].failure_reason;
460458
hookData['hook_run'].failure_reason_expanded = uploadData['test_run'].failure_reason_expanded;
461459
hookData['hook_run'].failure_backtrace = uploadData['test_run'].failure_backtrace;
460+
if (hookData['hook_run']['hook_type'] === 'BEFORE_ALL') {
461+
hookData['hook_run'].finished_at = uploadData['test_run'].finished_at;
462+
hookData['hook_run'].duration_in_ms = new Date(hookData['hook_run'].finished_at).getTime() - new Date(hookData['hook_run'].started_at).getTime();
463+
} else {
464+
hookData['hook_run'].finished_at = hookData['hook_run'].started_at;
465+
hookData['hook_run'].duration_in_ms = 0;
466+
}
462467
await uploadEventData(hookData);
463468
})
464469
this.hooksStarted = {};

0 commit comments

Comments
 (0)