-
Notifications
You must be signed in to change notification settings - Fork 1
Backend Tests
Dinith edited this page May 24, 2020
·
5 revisions
-
- Allows easy testing of any JS code
- Allows use of mocks
- Allows use of spies
-
- Allows mocking of Mongoose models
- Can mock Mongoose method calls on the models
-
- Allows mocking of a MongoDb server
- Creates an in-memory database
Testing of the backend's methods was done, namely the methods that make API calls to Spotify's API. This required the following:
- Mocking of the
node-fetch
module, which was used to make API calls - Checking the number of calls to the
fetch
method - Checking the inputs to the
fetch
method
Metrinom has one model - User
. This stores user information made to use API calls and display non-sensitive user data on the frontend. User
JSON objects are stored in a collection of the MongoDb database. This required the following:
- Use of
monogodb-memory-server
to mock a database - Checking retrieval, creation and deletion of
User
objects from/to the database