Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 2.64 KB

CYPRESS.md

File metadata and controls

41 lines (27 loc) · 2.64 KB

Cypress Testing Guide

Prerequisites

  • 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.

Summary

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.

Set-Up:

To set-up, configure the Cypress variables in env.local.

  1. For CYPRESS_PROJECT_ID: Get started with Cypress and use your Cypress project ID.
  2. For CYPRESS_MAIL_SLURP_API_KEY and CYPRESS_INBOX_ID: Create a Mailslurp account, navigate to your dashboard to obtain the API key, then create an Mailslurp inbox.
  3. 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.

Run Tests:

To run the tests, follow the instructions below:

  1. Ensure prerequisites are met.
  2. Ensure the local database contains users with emails matching those in the env.local file.
  3. Ensure Chrome is available on your local machine.
  4. 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
  5. Cypress will now open a new screen displaying the available test (this may take upto a minute the first the command runs).
  6. Click on the test you'd like to run. This will open another Chrome window and the chosen test will now run.

Test Coverage

A code coverage report can be generated by running yarn cypress:coverage. This will generate two reports:

  1. A coverage summary in the terminal
  2. 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