Making assertions about the POST request

We'll start with the status. I'm going to expect that the status equals 200, which should be the case when we send across valid data. After this, we can go ahead and make an assertion about the body that comes back. We want to make sure the body is an object and that it has the text property equal to the one we specified previously. That's exactly what it should be doing when it sends the body back.

Over inside of server.test.js, we can get that done by creating a custom expect assertion. If you can recall, our custom expect calls do get passed in the response, and we can use that response inside of the function. We're going to expect that the response body has a text property and that the text property ...

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.