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 ...
Test 2 - Verifying invalid ID
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.