@@ -34,10 +34,9 @@ exports.setAccessibilityCypressCapabilities = async (user_config, accessibilityR
34
34
35
35
exports . createAccessibilityTestRun = async ( user_config , framework ) => {
36
36
37
- const userName = user_config [ "auth" ] [ "username" ] ;
38
- const accessKey = user_config [ "auth" ] [ "access_key" ] ;
39
-
40
37
try {
38
+ const userName = user_config [ "auth" ] [ "username" ] ;
39
+ const accessKey = user_config [ "auth" ] [ "access_key" ] ;
41
40
let settings = user_config . run_settings . accessibilityOptions ;
42
41
43
42
const {
@@ -83,14 +82,15 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
83
82
'POST' , 'test_runs' , data , config
84
83
) ;
85
84
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
+
90
92
this . setAccessibilityCypressCapabilities ( user_config , response . data ) ;
91
93
setAccessibilityEventListeners ( ) ;
92
- // setEventListeners();
93
-
94
94
95
95
} catch ( error ) {
96
96
if ( error . response ) {
@@ -100,7 +100,7 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
100
100
} ${ error . response . statusText } ${ JSON . stringify ( error . response . data ) } `
101
101
) ;
102
102
} else {
103
- if ( error . message == 'Invalid configuration passed.' ) {
103
+ if ( error . message === 'Invalid configuration passed.' ) {
104
104
logger . error (
105
105
`Exception while creating test run for BrowserStack Accessibility Automation: ${
106
106
error . message || error . stack
0 commit comments