You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: integrate cypress-axe for accessibility testing (#11128)
**Note: These changes are intended for use within the monorepo only**
These changes are integrating the `cypress-axe` plugin to enable accessibility testing within the UI5 webcomponents project. As part of the integration, a new `CYPRESS_UI5_ACC` environment has been added to control the execution of accessibility tests. When set to `true`, it allows generating an accessibility report otherwise, the tests are skipped.
Additionally, a new global function, `ui5AccDescribe`, has been introduced for test files. This function acts as a wrapper around the standard `describe` function, accepting the same parameters. Internally, it determines whether to run or skip tests based on the `CYPRESS_UI5_ACC` value. The wrapper also injects the necessary `axe-core` tool and includes the `ui5CheckA11y` command, which is used for accessibility validation.
**Note: If `CYPRESS_UI5_ACC` is set, only accessibility tests will run**
Furthermore, the `ui5CheckA11y` command has been added to execute `axe` on mounted content.
Related to: #11128
// Reset the report file when tests are run with the `cypress run` command.
74
+
// This event is triggered when running tests with the `cypress open` command (behind an experimental flag).
75
+
// `config.isInteractive` helps us determine whether the tests are running in interactive mode (`cypress open`) or non-interactive mode (`cypress run`).
76
+
if(!config.isInteractive){
77
+
prepare();
78
+
}
79
+
});
80
+
81
+
on('before:browser:launch',()=>{
82
+
// Reset the report file when tests are run with the `cypress open` command.
83
+
// `config.isInteractive` helps us determine whether the tests are running in interactive mode (`cypress open`) or non-interactive mode (`cypress run`).
84
+
if(config.isInteractive){
85
+
prepare();
86
+
}
87
+
});
88
+
89
+
on('task',{
90
+
// Adds the accessibility report for the current test to the spec file logs
91
+
ui5ReportA11y(report: TestReport){
92
+
log(report);
93
+
94
+
returnnull;
95
+
},
96
+
97
+
// Removes all existing logs for the current test file when the spec file is loaded
0 commit comments