Cypress functional tests for Purple A11y to verify the correctness of Purple A11y CLI and integration module.
- Edit the /etc/hosts file by running
sudo nano /etc/hostsin terminal. - At the end of the file, add these new lines with the following format:
127.0.0.1 main.purplea11y.local
127.0.0.1 diffHostname.purplea11y.local
This is needed to test the strategy flag in Purple A11y.
- Install dependencies then run the
host_websites_and_run_cypress.shscript, which hosts the functional test website on a python server then runs the cypress tests.
Note: Thehost_websites_and_run_cypress.shscript accepts an argument that specifies the package of Purple A11y you want to test. To test your specific branch of Purple A11y, just change "master" with your preferred branch. (see below)
npm install
shell_scripts/host_websites_and_run_cypress.sh git+https://github.com/GovTechSG/purple-a11y.git#master
-
After running the
shell_scripts/host_websites_and_run_cypress.shscript, find generated cypress report under./cypress/reports/index.htmlfrom project root directory. -
If you make code changes in the
srcfolder, ensure you donpm run buildto compile the typescript into thedistfolder.
Ensure that you have these installed:
- Colima on MacOS, or Docker Engine on Linux or Windows (via Linux VM)
- Docker (install via
brew install docker)
colima start
Note: The start_docker.sh script accepts an argument that specifies the package of Purple A11y you want to test. To test your specific branch of Purple A11y, just change "master" with your preferred branch. (see below)
shell_scripts/start_docker.sh git+https://github.com/GovTechSG/purple-a11y.git#master
shell_scripts/stop_docker.sh
- Cypress tests report will then be copied over from inside the container to your local repo at ./cypress/reports (view
index.htmlfor report)
colima stop
Test changes to tests by triggering Actions to run the test on any branch of tests or purple-a11y.
- Go to Actions tab.
- Select
Run workflowand choose the branch underUse workflow fromto change the tests branch. - Optionally, the different git+URL of Purple A11y to change the branch of Purple A11y in
Checkout a specific purple a11y branch.
- Docker can only run Chromium in headless mode or through Xvfb (
xvfb-run). - The tests will not run successfully on Chrome or Edge in Docker.