Skip to content
This repository was archived by the owner on Mar 7, 2023. It is now read-only.

Testing

Ben Mitchinson edited this page Apr 6, 2020 · 5 revisions

Frontend Testing

Unit Tests (Jest)

We use unit tests to test components in isolation with react-testing-library, and hooks with react-hooks-testing-library. All unit test coverage must surpass 90% to be merged into the codebase, and github actions support to run our tests in the cloud is currently WIP.

Integration Tests (Cypress)

Cypress does user interaction tests, which we define as integration tests. These are not implemented into our coverage, but are there as an additional measure to ensure common user flows through the application are never damaged.

All tests / code are constructed from typescript models, which will align with what we receive from PostgREST.

Commands to execute all of the above tests and their reports are listed in the package.json

Commands: These commands should be run from within the PWA container with everything spun up. If you don't want an interactive bash prompt within the terminal, you can issue the command to run them from the outside with docker exec haiti_pwa {command}

  • npm run test runs the unit tests in watch mode
  • npm run test:cov runs all tests once, and reports the results + a coverage report
  • npm run cy:run runs the interaction tests in "headless mode" meaning a browser isn't opened for you to see
  • npm run cy:open runs the interaction tests in "non headless mode" meaning you see a browser visually run the tests

Clone this wiki locally