@@ -15,25 +15,31 @@ const HttpsProxyAgent = require('https-proxy-agent');
15
15
exports . checkAccessibilityPlatform = ( user_config ) => {
16
16
let accessibility = false ;
17
17
try {
18
+ console . debug ( '[A11Y][helper] Checking accessibility platform. Browsers:' , user_config . browsers ) ;
18
19
user_config . browsers . forEach ( browser => {
19
20
if ( browser . accessibility ) {
20
21
accessibility = true ;
22
+ console . debug ( `[A11Y][helper] Accessibility enabled for browser:` , browser ) ;
21
23
}
22
24
} )
23
- } catch { }
24
-
25
+ } catch ( err ) {
26
+ console . debug ( '[A11Y][helper] Error checking accessibility platform:' , err ) ;
27
+ }
28
+ console . debug ( `[A11Y][helper] Accessibility platform result: ${ accessibility } ` ) ;
25
29
return accessibility ;
26
30
}
27
31
28
32
exports . setAccessibilityCypressCapabilities = async ( user_config , accessibilityResponse ) => {
29
33
if ( utils . isUndefined ( user_config . run_settings . accessibilityOptions ) ) {
30
34
user_config . run_settings . accessibilityOptions = { }
31
35
}
36
+ console . debug ( '[A11Y][helper] Setting Cypress capabilities for accessibility:' , accessibilityResponse . data ) ;
32
37
user_config . run_settings . accessibilityOptions [ "authToken" ] = accessibilityResponse . data . accessibilityToken ;
33
38
user_config . run_settings . accessibilityOptions [ "auth" ] = accessibilityResponse . data . accessibilityToken ;
34
39
user_config . run_settings . accessibilityOptions [ "scannerVersion" ] = accessibilityResponse . data . scannerVersion ;
35
40
user_config . run_settings . system_env_vars . push ( `ACCESSIBILITY_AUTH=${ accessibilityResponse . data . accessibilityToken } ` )
36
41
user_config . run_settings . system_env_vars . push ( `ACCESSIBILITY_SCANNERVERSION=${ accessibilityResponse . data . scannerVersion } ` )
42
+ console . debug ( '[A11Y][helper] Updated user_config.run_settings:' , user_config . run_settings ) ;
37
43
}
38
44
39
45
exports . isAccessibilitySupportedCypressVersion = ( cypress_config_filename ) => {
@@ -44,8 +50,9 @@ exports.isAccessibilitySupportedCypressVersion = (cypress_config_filename) => {
44
50
exports . createAccessibilityTestRun = async ( user_config , framework ) => {
45
51
46
52
try {
53
+ console . debug ( '[A11Y][helper] Starting createAccessibilityTestRun' ) ;
47
54
if ( ! this . isAccessibilitySupportedCypressVersion ( user_config . run_settings . cypress_config_file ) ) {
48
- logger . warn ( `Accessibility Testing is not supported on Cypress version 9 and below.` )
55
+ logger . warn ( `[A11Y][helper] Accessibility Testing is not supported on Cypress version 9 and below.` )
49
56
process . env . BROWSERSTACK_TEST_ACCESSIBILITY = 'false' ;
50
57
user_config . run_settings . accessibility = false ;
51
58
return ;
@@ -59,6 +66,7 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
59
66
projectName,
60
67
buildDescription
61
68
} = helper . getBuildDetails ( user_config ) ;
69
+ console . debug ( '[A11Y][helper] Build details:' , { buildName, projectName, buildDescription } ) ;
62
70
63
71
const data = {
64
72
'projectName' : projectName ,
@@ -85,6 +93,7 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
85
93
} ,
86
94
'browserstackAutomation' : process . env . BROWSERSTACK_AUTOMATION === 'true'
87
95
} ;
96
+ console . debug ( '[A11Y][helper] Test run payload:' , data ) ;
88
97
89
98
const config = {
90
99
auth : {
@@ -95,35 +104,40 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
95
104
'Content-Type' : 'application/json'
96
105
}
97
106
} ;
107
+ console . debug ( '[A11Y][helper] Test run config:' , config ) ;
98
108
99
109
const response = await nodeRequest (
100
110
'POST' , 'v2/test_runs' , data , config , API_URL
101
111
) ;
112
+ console . debug ( '[A11Y][helper] Test run response:' , response . data ) ;
102
113
if ( ! utils . isUndefined ( response . data ) ) {
103
114
process . env . BS_A11Y_JWT = response . data . data . accessibilityToken ;
104
115
process . env . BS_A11Y_TEST_RUN_ID = response . data . data . id ;
116
+ console . debug ( `[A11Y][helper] Set BS_A11Y_JWT: ${ process . env . BS_A11Y_JWT } , BS_A11Y_TEST_RUN_ID: ${ process . env . BS_A11Y_TEST_RUN_ID } ` ) ;
105
117
}
106
118
if ( process . env . BS_A11Y_JWT ) {
107
119
process . env . BROWSERSTACK_TEST_ACCESSIBILITY = 'true' ;
120
+ console . debug ( '[A11Y][helper] Accessibility session enabled' ) ;
108
121
}
109
- logger . debug ( `BrowserStack Accessibility Automation Test Run ID: ${ response . data . data . id } ` ) ;
122
+ logger . debug ( `[A11Y][helper] BrowserStack Accessibility Automation Test Run ID: ${ response . data . data . id } ` ) ;
110
123
111
124
this . setAccessibilityCypressCapabilities ( user_config , response . data ) ;
112
125
helper . setBrowserstackCypressCliDependency ( user_config ) ;
113
126
114
127
} catch ( error ) {
128
+ console . debug ( '[A11Y][helper] Error in createAccessibilityTestRun:' , error ) ;
115
129
if ( error . response ) {
116
130
logger . error ( "Incorrect Cred" )
117
131
logger . error (
118
- `Exception while creating test run for BrowserStack Accessibility Automation: ${
132
+ `[A11Y][helper] Exception while creating test run for BrowserStack Accessibility Automation: ${
119
133
error . response . status
120
134
} ${ error . response . statusText } ${ JSON . stringify ( error . response . data ) } `
121
135
) ;
122
136
} else {
123
137
if ( error . message === 'Invalid configuration passed.' ) {
124
138
logger . error ( "Invalid configuration passed." )
125
139
logger . error (
126
- `Exception while creating test run for BrowserStack Accessibility Automation: ${
140
+ `[A11Y][helper] Exception while creating test run for BrowserStack Accessibility Automation: ${
127
141
error . message || error . stack
128
142
} `
129
143
) ;
@@ -133,7 +147,7 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
133
147
134
148
} else {
135
149
logger . error (
136
- `Exception while creating test run for BrowserStack Accessibility Automation: ${
150
+ `[A11Y][helper] Exception while creating test run for BrowserStack Accessibility Automation: ${
137
151
error . message || error . stack
138
152
} `
139
153
) ;
0 commit comments