Automated tests on Cypress
Quick start guide to integrate Automated tests on BrowserStack Accessibility Testing with Cypress.
Prerequisites
- You have an account with BrowserStack (even a free trial works) and can get your Username and Access Key from Account & Profile.
- You have a pre-existing Cypress test suite (version 10 or above) integrated with BrowserStack Automate.
- Automated tests will not run on legacy headless mode. Switch to new headless mode or avoid using headless mode (add
headless:false
tobrowserstack.json
).
Integrate with Automated tests on BrowserStack Accessibility Testing
Follow these steps to get started with adding Automated tests to your test suite:
The minimum version of browserstack-cypress-cli
that supports Automated tests is 1.29.0
.
Install the latest version of the browserstack-cypress-cli npm package
Update the browserstack-cypress-cli
using the following commands.
Make changes to the browserstack.json file
Verify that your browserstack.json
config file has all the required key-value pairs as in the following snippet. Especially, ensure to set the accessibility
flag as true
.
The projectName and buildName config must be static and not change across different runs of the same build. This is a deviation in approach as specified by BrowserStack Automate since Automated tests will automatically identify different build runs.
Accessibility testing runs only on Desktops (Mac & Windows) with Chrome 100 & above on Automate.
In case of non-default directory structure or TypeScript, it is recommended to add the following require()
or import
statement in the Javascript/Typescript file(s) containing custom commands: require('browserstack-cypress-cli/bin/accessibility-automation/cypress');
or import 'browserstack-cypress-cli/bin/accessibility-automation/cypress';
.
Automated tests with Cypress doesn’t work if headless mode is set to true
in the browserstack.json
file.
Make changes to the cypress.config.js file
You’ll need to make a minor modification to the cypress.config.js
file to import and use the Automated tests plugin while your tests run. Ensure the lines mentioned in the following sample file are present in your config file. Especially, ensure to set browserstackAccessibility
as on
as in the following snippet.
Run your suite with Automated tests
Continue running your tests as you have been running previously. The command to run your tests using the BrowserStack SDK remains unchanged. For your reference, here’s a sample command:
You can check the Accessibility report for your build through the Automated tests page.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!