From e98f74b55c9761169592b71b1d40c6cd5f06d8fb Mon Sep 17 00:00:00 2001 From: Pranay Kumar Date: Fri, 26 May 2023 16:39:36 +0530 Subject: [PATCH] vc_file_path fix and timestamp issue --- src/testObservability.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/testObservability.js b/src/testObservability.js index 60166c2..d65ccd7 100644 --- a/src/testObservability.js +++ b/src/testObservability.js @@ -243,7 +243,7 @@ class TestObservability { identifier: `${testFileReport.name} - ${skippedTest}`, file_name: path.relative(process.cwd(), testFileReport.modulePath), location: path.relative(process.cwd(), testFileReport.modulePath), - vc_filepath: this._gitMetadata ? path.relative(this._gitMetadata.root, testFileReport.modulePath) : null, + vc_filepath: (this._gitMetadata && this._gitMetadata.root) ? path.relative(this._gitMetadata.root, testFileReport.modulePath) : null, started_at: new Date(testFileReport.endTimestamp).toISOString(), finished_at: new Date(testFileReport.endTimestamp).toISOString(), duration_in_ms: 0, @@ -315,7 +315,7 @@ class TestObservability { identifier: `${testFileReport.name} - ${sectionName}`, file_name: path.relative(process.cwd(), testFileReport.modulePath), location: path.relative(process.cwd(), testFileReport.modulePath), - vc_filepath: this._gitMetadata ? path.relative(this._gitMetadata.root, testFileReport.modulePath) : null, + vc_filepath: (this._gitMetadata && this._gitMetadata.root) ? path.relative(this._gitMetadata.root, testFileReport.modulePath) : null, started_at: new Date(eventData.startTimestamp).toISOString(), result: 'pending', framework: 'nightwatch', @@ -323,7 +323,7 @@ class TestObservability { }; if (eventType === 'HookRunFinished' || eventType === 'TestRunFinished') { - testData.finished_at = new Date(eventData.endTimestamp).toISOString(); + testData.finished_at = eventData.endTimestamp ? new Date(eventData.endTimestamp).toISOString() : new Date(eventData.startTimestamp).toISOString(); testData.result = eventData.status === 'pass' ? 'passed' : 'failed'; testData.duration_in_ms = 'timeMs' in eventData ? eventData.timeMs : eventData.time; if (eventData.status === 'fail' && eventData.lastError) {