Automated tests ¶
Cypress ¶
Feature and user interface tests are implemented with cypress
and can be found in the
tests/cypress
directory in the repository.
See the cypress
Command Line guide for more information.
Running ¶
These are instructions for running cypress
locally on your machine, without the devcontainer. These steps
will install cypress
and its dependencies on your machine. Make sure to run these commands in a Terminal.
-
Ensure you have Node.js and NPM available on your local machine:
node -v npm -v
If not, install Node.js locally.
-
Start the local eligibility verification server:
docker compose up --detach server
-
Start the the application:
docker compose run --detach --service-ports client bin/test_start.sh
-
Change into the
cypress
directory:cd tests/cypress
-
Install all packages and
cypress
. Verifycypress
installation succeeds:npm install
-
Run
cypress
with test environment variables and configuration variables:CYPRESS_baseUrl=http://localhost:8000 npm run cypress:open
See tests/cypress/package.json
for more cypress scripts.
As of Cypress 12.5.1 with Firefox 109, there is a CSRF issue that prevents the tests from passing; unclear if this is a bug in Cypress or what. Use one of the other browser options.
Pytest ¶
The tests done at a request/unit level are run via pytest-django.
To run locally, start the Devcontainer and run:
tests/pytest/run.sh
The helper script:
- Runs the tests with
pytest
- Calculates test coverage with
coverage
- Generates a
coverage
report in HTML in the app’sstatic/
directory
The report can be viewed by launching the app and navigating to http://localhost:$DJANGO_LOCAL_PORT/static/coverage/index.html
The report files include a local .gitignore
file, so the entire directory is hidden from source control.
Latest coverage report ¶
We also make the latest (from main
) coverage report available online here: Coverage report