Week 17 - Testing
Overview
After finishing the functionalities of our application, we spent time this week focusing on the testing of the app. Ensuring there should not be bugs and finding potential crashes.
Testing
We have decided to use Jest as our testing framework. It is a very popular testing library with thorough documentation and compatible with React and NodeJS. We also used NYC Istanbul which get the coverage for the integration tests.
The image below shows all our tests which are close to 100% coverage in both our unit and integration test for our backend.
Front end – Snapshot Testing
We use snapshot testing as a way to prevent any regressions in our front end components. We have created 9 snapshots. We also set up the states in order to test our components accurately. All the 9 tests have passed which gave us the confidence that our components are operating as intended. Several bugs were also fixed during the snapshot testing process.
Back end – Unit and Integration Testing
We have six test suits which passed 72 tests for our back end endpoints. This consists of both unit tests and integration tests. The authorized
and validInfo
are unit tests for our middleware functions and they passed. Integration tests are done with Jest
and Istanbul
to simulate and run our backend to get our back end coverage. We mocked our database to create some dummy data every time to test our endpoints. There is an SQL script that we run to drop our testing database and to recreate schema. The tests cases are run sequentially We also sequentially, starting from JWTauth
which will create the dummy data for the next tests. Since we are performing the integration test for four files, which are JWTauth
, getFeeds
, myPatients
and patientInfo
, We used Istanbul
for getting the coverage of those integration test for the back end. This also gives us confidence that our back end endpoints are performing and working correctly.
Next Steps
We would like to carry on fully testing our program by doing the end-to-end testing with Cypress
. This is to test the entire app for both the front and back end. Also, we can add continuous integration through GitHub actions.