We're going to expect that a 200 comes back and we're also going to create a custom assertion, expecting something about the body. We'll provide our callback function with the response and we're going to expect that res.body.todos has a length of 2, .toBe(2). Now that we have this in place, all we have to do is tack on an end call, and pass in done as the argument.
describe('GET /todos', () => { it('should get all todos', (done) => { request(app) .get('/todos') .expect(200) .expect((res) => { expect(res.body.todos.length).toBe(2); }) .end(done); )}; });
There is no need to provide a function to end, because we're not doing anything asynchronously.
With this in place, we are now good to go. We can save the ...