Now we haven't talked about how to set a custom status for our response, but we can do that with one method, .status. Let's add .status in server.js, chaining it on, before, send('Hello world!'), just like this:
app.get('/', (req, res) => {
res.status().send('Hello world!');
});
Then, we can pass in the numerical status code. For example, we could use a 404 for page not found:
app.get('/', (req, res) => {
res.status(404).send('Hello world!');
});
If we save the file this time around, the body is going to match up, but inside the Terminal we can see we now have a different error:

We expected a 200, but we got a 404. Using SuperTest, we can make all sorts of assertions about our application. Now the same thing is true for different types of responses. For example, we can create an object as the response. Let's make a simple object and we'll create a property called error. Then we'll set error equal to a generic error message for a 404, something like Page not found:
app.get('/', (req, res) => {
res.status(404).send({
error: 'Page not found.'
});
});
Now, we're sending back a JSON body, but currently we're not making any assertions about that body so the test is going to fail:

We can update our tests to expect JSON to come back. In order to get that done, all we have to do inside server.test is change what we pass to expect. Instead of passing in a string, we'll pass in an object:
it('should return hello world response', (done) => {
request(app)
.get('/')
.expect(200)
.expect({
})
.end(done);
});
Now we can match up that object exactly. Inside the object, we'll expect that the error property exists and that it equals exactly what we have in server.js:
.expect({
error: 'Page not found.'
})
Then, we'll change the .expect call to a 404 from 200:
.expect(404)
.expect({
error: 'Page not found.'
})
With this in place, our assertions now match up with the actual endpoint we've defined inside the Express application. Let's save the file and see if all the tests pass:

As shown in the previous screenshot, we can see it is indeed passing. The Should return hello world response is passing. It took about 41ms (milliseconds) to complete, and that is perfectly fine.