@@ -78,11 +78,13 @@ const supportFileCleanup = () => {
7878 } ) ;
7979}
8080
81- exports . printBuildLink = async ( ) => {
81+ exports . printBuildLink = async ( shouldStopSession , exitCode = null ) => {
8282 if ( ! this . isTestObservabilitySession ( ) ) return ;
8383 try {
84- supportFileCleanup ( ) ;
85- await this . stopBuildUpstream ( ) ;
84+ if ( shouldStopSession ) {
85+ supportFileCleanup ( ) ;
86+ await this . stopBuildUpstream ( ) ;
87+ }
8688 try {
8789 if ( process . env . BS_TESTOPS_BUILD_HASHED_ID
8890 && process . env . BS_TESTOPS_BUILD_HASHED_ID != "null"
@@ -96,6 +98,7 @@ exports.printBuildLink = async () => {
9698 } catch ( err ) {
9799 exports . debug ( `Error while stopping build with error : ${ err } ` , true , err ) ;
98100 }
101+ if ( exitCode ) process . exit ( exitCode ) ;
99102}
100103
101104const nodeRequest = ( type , url , data , config ) => {
@@ -748,16 +751,28 @@ exports.isTestObservabilitySupportedCypressVersion = (cypress_config_filename) =
748751exports . setTestObservabilityFlags = ( bsConfig ) => {
749752 /* testObservability */
750753 let isTestObservabilitySession = true ;
751- if ( ! utils . isUndefined ( bsConfig [ "testObservability" ] ) ) isTestObservabilitySession = ( bsConfig [ "testObservability" ] == true || bsConfig [ "testObservability" ] == 1 ) ;
752- if ( ! utils . isUndefined ( process . env . BROWSERSTACK_TEST_OBSERVABILITY ) ) isTestObservabilitySession = ( process . env . BROWSERSTACK_TEST_OBSERVABILITY == "true" || process . env . BROWSERSTACK_TEST_OBSERVABILITY == "1" ) ;
753- if ( process . argv . includes ( '--disable-test-observability' ) ) isTestObservabilitySession = false ;
754- isTestObservabilitySession = isTestObservabilitySession && this . isTestObservabilitySupportedCypressVersion ( bsConfig . run_settings . cypress_config_file ) ;
754+ try {
755+ if ( ! utils . isUndefined ( bsConfig [ "testObservability" ] ) ) isTestObservabilitySession = ( bsConfig [ "testObservability" ] == true || bsConfig [ "testObservability" ] == 1 ) ;
756+ if ( ! utils . isUndefined ( process . env . BROWSERSTACK_TEST_OBSERVABILITY ) ) isTestObservabilitySession = ( process . env . BROWSERSTACK_TEST_OBSERVABILITY == "true" || process . env . BROWSERSTACK_TEST_OBSERVABILITY == "1" ) ;
757+ if ( process . argv . includes ( '--disable-test-observability' ) ) isTestObservabilitySession = false ;
758+ isTestObservabilitySession = isTestObservabilitySession && this . isTestObservabilitySupportedCypressVersion ( bsConfig . run_settings . cypress_config_file ) ;
759+ } catch ( e ) {
760+ isTestObservabilitySession = false ;
761+ exports . debug ( `EXCEPTION while parsing testObservability capability with error ${ e } ` ) ;
762+ }
763+
755764
756765 /* browserstackAutomation */
757766 let isBrowserstackInfra = true ;
758- if ( ! utils . isUndefined ( bsConfig [ "browserstackAutomation" ] ) ) isBrowserstackInfra = ( bsConfig [ "browserstackAutomation" ] == true || bsConfig [ "browserstackAutomation" ] == 1 ) ;
759- if ( ! utils . isUndefined ( process . env . BROWSERSTACK_AUTOMATION ) ) isBrowserstackInfra = ( process . env . BROWSERSTACK_AUTOMATION == "true" || process . env . BROWSERSTACK_AUTOMATION == "1" ) ;
760- if ( process . argv . includes ( '--disable-browserstack-automation' ) ) isBrowserstackInfra = false ;
767+ try {
768+ if ( ! utils . isUndefined ( bsConfig [ "browserstackAutomation" ] ) ) isBrowserstackInfra = ( bsConfig [ "browserstackAutomation" ] == true || bsConfig [ "browserstackAutomation" ] == 1 ) ;
769+ if ( ! utils . isUndefined ( process . env . BROWSERSTACK_AUTOMATION ) ) isBrowserstackInfra = ( process . env . BROWSERSTACK_AUTOMATION == "true" || process . env . BROWSERSTACK_AUTOMATION == "1" ) ;
770+ if ( process . argv . includes ( '--disable-browserstack-automation' ) ) isBrowserstackInfra = false ;
771+ } catch ( e ) {
772+ isBrowserstackInfra = true ;
773+ exports . debug ( `EXCEPTION while parsing browserstackAutomation capability with error ${ e } ` ) ;
774+ }
775+
761776
762777 process . env . BROWSERSTACK_TEST_OBSERVABILITY = isTestObservabilitySession ;
763778 process . env . BROWSERSTACK_AUTOMATION = isBrowserstackInfra ;
@@ -961,7 +976,7 @@ exports.runCypressTestsLocally = (bsConfig, args, rawArgs) => {
961976 ) ;
962977 cypressProcess . on ( 'close' , async ( code ) => {
963978 logger . info ( `Cypress process exited with code ${ code } ` ) ;
964- await this . printBuildLink ( ) ;
979+ await this . printBuildLink ( true ) ;
965980 } ) ;
966981
967982 cypressProcess . on ( 'error' , ( err ) => {
0 commit comments