Backend unit tests are added in the /test branch (checkout to the branch and run npm test).
Given time limit, we only implemented basic unit tests for restaurant, review, reviewer GET routes. We may want to add more tests including auth and protected routes.
It may also be fun to look into other test frameworks such as Mocha and Chai.
Since we connect to the MySQL db using a connection pool, there is no need to establish a single connection to db before running tests. However, we should manually create a test user in beforeAll() and destroy it in afterAll() should we test auth or protected routes.
Backend unit tests are added in the
/test
branch (checkout to the branch and runnpm test
).Given time limit, we only implemented basic unit tests for restaurant, review, reviewer
GET
routes. We may want to add more tests including auth and protected routes.It may also be fun to look into other test frameworks such as Mocha and Chai.
Notes:
app.listen
will cause a jest open handle issue. This can be solved by extracting the logic to listen on port from the mainindex.js
file (https://stackoverflow.com/questions/51968480/jest-detects-open-handle-with-express-app)beforeAll()
and destroy it inafterAll()
should we test auth or protected routes.