From cefe480f650bf1a195075a579cc3978b5549994d Mon Sep 17 00:00:00 2001 From: prathams-cmd Date: Fri, 27 Mar 2026 19:46:10 +0530 Subject: [PATCH] Fix: Double logs fix --- bin/testObservability/reporter/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/testObservability/reporter/index.js b/bin/testObservability/reporter/index.js index e4a0fdfc..79f4e387 100644 --- a/bin/testObservability/reporter/index.js +++ b/bin/testObservability/reporter/index.js @@ -332,6 +332,16 @@ class MyReporter { uploadTestSteps = async (shouldClearCurrentSteps = true, cypressSteps = null) => { const currentTestSteps = cypressSteps ? cypressSteps : JSON.parse(JSON.stringify(this.currentTestSteps)); + + // This prevents subsequent Mocha events from grabbing the same stale steps. + if(shouldClearCurrentSteps && !cypressSteps) { + this.currentTestSteps = []; + } + + if (!currentTestSteps || currentTestSteps.length === 0) { + return; + } + /* TODO - Send as test logs */ const allStepsAsLogs = []; currentTestSteps.forEach(step => { @@ -350,11 +360,11 @@ class MyReporter { }; allStepsAsLogs.push(currentStepAsLog); }); + await uploadEventData({ event_type: 'LogCreated', logs: allStepsAsLogs }); - if(shouldClearCurrentSteps) this.currentTestSteps = []; } sendTestRunEvent = async (test, err = undefined, customFinished=false, eventType = "TestRunFinished") => {