Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions bin/helpers/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
2 changes: 1 addition & 1 deletion bin/testObservability/helper/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions bin/testObservability/reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'] = {
Expand Down