@@ -34,10 +34,9 @@ exports.setAccessibilityCypressCapabilities = async (user_config, accessibilityR
3434
3535exports . createAccessibilityTestRun = async ( user_config , framework ) => {
3636
37- const userName = user_config [ "auth" ] [ "username" ] ;
38- const accessKey = user_config [ "auth" ] [ "access_key" ] ;
39-
4037 try {
38+ const userName = user_config [ "auth" ] [ "username" ] ;
39+ const accessKey = user_config [ "auth" ] [ "access_key" ] ;
4140 let settings = user_config . run_settings . accessibilityOptions ;
4241
4342 const {
@@ -83,14 +82,15 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
8382 'POST' , 'test_runs' , data , config
8483 ) ;
8584 logger . info ( "response in createAccessibilityTestRun" , response ) ;
86- process . env . BROWSERSTACK_TEST_ACCESSIBILITY = 'true' ;
87- process . env . BS_A11Y_JWT = response . data . data . accessibilityToken ;
88- process . env . BS_A11Y_TEST_RUN_ID = response . data . data . id ;
89-
85+ process . env . BS_A11Y_JWT = response ?. data ?. data ?. accessibilityToken ;
86+ process . env . BS_A11Y_TEST_RUN_ID = response ?. data ?. data ?. id ;
87+
88+ if ( process . env . BS_A11Y_JWT ) {
89+ process . env . BROWSERSTACK_TEST_ACCESSIBILITY = 'true' ;
90+ }
91+
9092 this . setAccessibilityCypressCapabilities ( user_config , response . data ) ;
9193 setAccessibilityEventListeners ( ) ;
92- // setEventListeners();
93-
9494
9595 } catch ( error ) {
9696 if ( error . response ) {
@@ -100,7 +100,7 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
100100 } ${ error . response . statusText } ${ JSON . stringify ( error . response . data ) } `
101101 ) ;
102102 } else {
103- if ( error . message == 'Invalid configuration passed.' ) {
103+ if ( error . message === 'Invalid configuration passed.' ) {
104104 logger . error (
105105 `Exception while creating test run for BrowserStack Accessibility Automation: ${
106106 error . message || error . stack
0 commit comments