- Chrome internet browser (or Chromium with 'chrome' alias on Linux).
- Backend is running, and database populated with test data.
- Frontend is runnning, must be on
localhost:3000
port.
We use Cypress for integration testing and MailSlurp for email tesitng. Integration tests run locally with Chrome. In GitHub Action CI workflows, it runs against the staging backend. Cypress tests require the frontend running on localhost:3000
port and backend running with populated database.
To set-up, configure the Cypress variables in env.local
.
- For
CYPRESS_PROJECT_ID
: Get started with Cypress and use your Cypress project ID. - For
CYPRESS_MAIL_SLURP_API_KEY
andCYPRESS_INBOX_ID
: Create a Mailslurp account, navigate to your dashboard to obtain the API key, then create an Mailslurp inbox. - For local Bloom Users: Create local Bloom users from your local frontend. You will need a public user, a super admin user, and 2 partner admin users. Directions in BLOOM_USERS.md.
For additional guidance setting up Cypress environemnt variables, check out our Chayn Tech Wiki Guide.
To run the tests, follow the instructions below:
- Ensure prerequisites are met.
- Ensure the local database contains users with emails matching those in the
env.local
file. - Ensure Chrome is available on your local machine.
- Run the command
yarn cypress
on your terminal to run tests in the browser.- To run a faster, head-less version of the tests (i.e. no visible browser), use the command
yarn cypress:headless
. - Run single tests at a time by running
./node_modules/.bin/cypress run --spec cypress/integration/example_test_PATH.cy.tsx
- To run a faster, head-less version of the tests (i.e. no visible browser), use the command
- Cypress will now open a new screen displaying the available test (this may take upto a minute the first the command runs).
- Click on the test you'd like to run. This will open another Chrome window and the chosen test will now run.
A code coverage report can be generated by running yarn cypress:coverage
. This will generate two reports:
- A coverage summary in the terminal
- An
index.html
page found in./coverage
which provides details of what lines of code have or have not been covered by tests, and can be viewed in a browser