The second test you're going to write is going to verify that when we have an invalid ID we get back a 404 response code, it('should return 404 for non-object ids'). This is also going to be an async test, so we'll specify done. For this one, you're going to pass in a URL, something like this: /todos/123. This is indeed a valid URL, but when we try to convert 123 to an ObjectID it's going to fail, and that should trigger the return res.status(404).send() code and we should get a 404 response code back. Once again, the only expectation you need to set up for this test is that when you make the get request to the URL a 404 is the status code. Take a moment to knock out both of these test cases, making sure they work as expected when you actually have the calls set up. If all of your test cases are passing over in the Terminal when you're done, then you are ready to move on.
For the first one, I'm going to go ahead and get that HexString by creating a variable. Now, you didn't need to create a variable; you could have done it slightly differently. I'm going to make a variable called hexId, setting it equal to new ObjectID. Now on this ObjectID we do want to call that toHexString method which we used before. This takes our ObjectID and gives us a string, and we can specify that string as part of the URL. Now, it's fine if you did this inside of the get call, kind of like we do here; either way works as long as the test case passes. We're going to call request, passing in our app. Next up, we are going to make a get request, so I'll call that get method and we can set up our URL. This one is going to be /todos/ and we're going to inject in our template string that hexId value. The only expectation we need to set up is that a 404 status code comes back. We're expecting 404. We can wrap this test case up by calling end, passing in our done function:
it('should return 404 if todo not found', (done) => {
var hexId = new ObjectID().toHexString();
request(app)
.get(`/todos/${hexId}`)
.expect(404)
.end(done);
});
it('should return 404 for non-object ids', (done) => {
// /todos/123
});
Now we can save the file and this test case should rerun. The last test is still going to fail, but that's fine, and over here you can see we get exactly that, should return todo doc passes and should return 404 if todo not found passes:

And the last test to write is what happens when we have an invalid ObjectID.