Test 3 - Validating invalid ObjectID

I'm going to call request, passing in app, then I'm going to go ahead and call get, setting up the URL. We don't need to use template strings here since we're just going to be passing in a plain string, /todos/123abc. Indeed an invalid ObjectID. The ObjectIDs, as we talked about, have a very specific structure and this does not pass that criteria. To find out more about ObjectIDs you can always go back to the ObjectID section at the beginning of this chapter. Next, we're going to start setting up our assertions by calling expect and expecting 404 to come back, and we can wrap this test up by calling the end method and passing in done:

it('should return 404 for non-object ids', (done) => { request(app) ...

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.