Adding testing life cycle method in server.test.js file

The beforeEach method is going to let us run some code before every single test case. We're going to use beforeEach to set up the database in a way that's useful. For now, all we're going to do is make sure the database is empty. We're going to pass in a function, that function is going to get called with a done argument, just like our individual test cases are.

const {Todo} = require('./../models/todo');    beforeEach((done) => {

});

This function is going to run before every test case and it's only going to move on to the test case once we call done, which means we can do something asynchronous inside of this function. What I'm going to do is call Todo.remove, which is similar to the ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.