We're going to get started by creating our super test request. We're going to request something from the app express application; it is going to be a get request, that is, the URL we're testing, and the actual URL is going to be /todos/id, where id equals one of these _ids in todos. I'm going to go ahead and use the _id of the first todo. Down below we can fix this by changing our string to a template string, so we can inject _id, /todos/ then we're going to add our syntax for injecting a value into the template string. In this case we're accessing something from the todos array. We want to grab the first item, this is the first todo, and we're looking for its _id property. Now, this is an ObjectID; we need to convert this into a string because that is what we're going to pass in as the URL. To convert an ObjectID to a string we can use the toHexString method:
describe('GET /todos/:id', () => {
it('should return todo doc', (done) => {
request(app)
.get(`/todos/${todos[0]._id.toHexString()}`)
});
});
There we go. Now we've generated the proper ID and we can start making some assertions about what should happen when this request gets fired. First up, the HTTP status code. That should be a 200, so I can call expect, passing in 200. Next step: we do want to verify that the body that comes back matches the body previous in the todos array, most notably that the text property equals the text property we set. I'm going to create a custom expect call to get that done. We'll pass in our function that gets called with the response object, and now we can make an assertion using the expect library. I'm going to use expect(res.body.todo), which we set up in res.send({todo}) when we used the ES6 object syntax, and that todo property has a text property that is equal to using toBe, the text property of our first todo. That's going to be todos, grabbing the first one, the zero-indexed todo, and we're going to grab its text property. With this in place, all of our assertions are done; we can call end, passing in done, which is going to wrap up the test case:
describe('GET /todos/:id', () => {
it('should return todo doc', (done) => {
request(app)
.get(`/todos/${todos[0]._id.toHexString()}`)
.expect((res) => {
expect(res.body.todo.text).toBe(todos[0].text);
})
.end(done); }); });
Now we can go ahead and run this test over inside of the Terminal by running npm run test-watch. This is going to kick off our test suite and we should have our new section with our test case that is passing:

Right here, we get should return todo doc, and that is passing, which is fantastic. Now it's time for you to write two test cases on your own. I'll give you the it calls so we're on the same page, but you are going to be responsible for filling out the actual test function, it('should return 404 if todo not found'). This is going to be an async test, so we'll specify the done argument, and your job here is going to be to make a request using a real ObjectID, and you're going to call its toHexString method. It is going to be a valid ID but it won't be found in the collection, so we should get a 404 back. Now, the only expectation you need to set up is the status code; make sure you get 404 back.