Skip to content

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.

  1. Ensure you have Node.js and NPM available on your local machine:

    node -v
    npm -v
    

    If not, install Node.js locally.

  2. Start the local eligibility verification server:

    docker compose up --detach server
    
  3. Start the the application:

    docker compose run --detach --service-ports client bin/test_start.sh
    
  4. Change into the cypress directory:

    cd tests/cypress
    
  5. Install all packages and cypress. Verify cypress installation succeeds:

    npm install
    
  6. 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:

  1. Runs the tests with pytest
  2. Calculates test coverage with coverage
  3. Generates a coverage report in HTML in the app’s static/ 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 dev) coverage report available online here: Coverage report