This demo project is to showcase how one can use Mocha Chai and Chai-http to test Rest Api's. It also has chai-json-schema to validate json schema's this includes Swagger and open-api3 specifications.
Nodejs 10 or later.
- Clone or Download the repo
git clone https://github.com/rupeshmore/mocha-chai-rest-api-tests
Download mocha-chai-rest-api-tests
Once the project is cloned or downloaded, go to the project folder and run
npm install
npm test
Start writing the test inside the test folder and change the configuration in config.js as per your project needs.
Define environment variable env to test against your desired test environment. The default environment is dev.
To validate the API's response against schema validations, use the json-schema library.
The test files demonstrate how to use them.
To change mocha configuration, edit the .mocharc.js file.