Testing server response
The question now is how can we test our Express instance. Well, there's a library designed exactly for this called Supertest.
In fact, this library was created by the developers who created Express and is therefore perfect for the job.
Let's install that by going:
$ npm i -D supertest@3
To use Supertest, let's first require it at the top of the file. The idiosyncratice way of using it is to assign the Supertest module to a constant called request
:
Click to load comments...