An example of automated testing a REST API using Jest and SuperTest.
Open a terminal, clone the repository, change to the directory and install dependencies:
git clone git@github.com:ashleydavis/javascript-testing-examples.git
cd javascript-testing-examples
cd rest-api-testing
npm installTo test the REST API manually you can run it like this:
npm startTo try out the REST API manually, point your browser at http://localhost:3000/an-example-api.
Note: to run these tests there is no need to manually start the REST API, runing the tests will take care of that.
Run the automated tests (Jest and SuperTest) like this:
npm test