diff --git a/bin/helpers/helper.js b/bin/helpers/helper.js index 9f5112b5..38696cb0 100644 --- a/bin/helpers/helper.js +++ b/bin/helpers/helper.js @@ -267,16 +267,26 @@ exports.getCiInfo = () => { return null; } -exports.getBuildDetails = (bsConfig) => { +exports.getBuildDetails = (bsConfig, isO11y = false) => { + const isTestObservabilityOptionsPresent = isO11y && !utils.isUndefined(bsConfig["testObservabilityOptions"]); + let buildName = '', projectName = '', buildDescription = '', buildTags = []; - + /* Pick from environment variables */ buildName = process.env.BROWSERSTACK_BUILD_NAME || buildName; projectName = process.env.BROWSERSTACK_PROJECT_NAME || projectName; - + + /* Pick from testObservabilityOptions */ + if(isTestObservabilityOptionsPresent) { + buildName = buildName || bsConfig["testObservabilityOptions"]["buildName"]; + projectName = projectName || bsConfig["testObservabilityOptions"]["projectName"]; + if(!utils.isUndefined(bsConfig["testObservabilityOptions"]["buildTag"])) buildTags = [...buildTags, ...bsConfig["testObservabilityOptions"]["buildTag"]]; + buildDescription = buildDescription || bsConfig["testObservabilityOptions"]["buildDescription"]; + } + /* Pick from run settings */ buildName = buildName || bsConfig["run_settings"]["build_name"]; projectName = projectName || bsConfig["run_settings"]["project_name"]; diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index c1b499dd..4534dcc2 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -331,7 +331,7 @@ exports.launchTestSession = async (user_config, bsConfigPath) => { projectName, buildDescription, buildTags - } = helper.getBuildDetails(user_config); + } = helper.getBuildDetails(user_config, true); const data = { 'format': 'json', 'project_name': projectName, diff --git a/bin/testObservability/reporter/index.js b/bin/testObservability/reporter/index.js index a460b8b6..33c515f6 100644 --- a/bin/testObservability/reporter/index.js +++ b/bin/testObservability/reporter/index.js @@ -156,14 +156,14 @@ class MyReporter { }) .on(EVENT_TEST_BEGIN, async (test) => { - if (test.isSkipped) return; + if (this.runStatusMarkedHash[test.testAnalyticsId]) return; if(this.testObservability == true) { await this.testStarted(test); } }) .on(EVENT_TEST_END, async (test) => { - if (test.isSkipped) return; + if (this.runStatusMarkedHash[test.testAnalyticsId]) return; if(this.testObservability == true) { if(!this.runStatusMarkedHash[test.testAnalyticsId]) { if(test.testAnalyticsId) this.runStatusMarkedHash[test.testAnalyticsId] = true; @@ -448,7 +448,7 @@ class MyReporter { } // Send pending hook finsihed events for hook starts - if (eventType === 'TestRunFinished') { + if (eventType === 'TestRunFinished' || eventType === 'TestRunSkipped') { Object.values(this.hooksStarted).forEach(async hookData => { hookData['event_type'] = 'HookRunFinished'; hookData['hook_run'] = {