REST API Testing with Typescript + Mocha + Chai Framework
- Node.js is installed
- Npm is installed
Mochaawesome Report - update package.json before run the test (Default Setting)
"scripts": {
"test": "mocha -r ts-node/register src/specs/**/*.ts --reporter mochaawesome"
},
Allure Report - update package.json before run the test (Alternative)
"scripts": {
"test": "mocha -r ts-node/register src/specs/**/*.ts --reporter mocha-allure-reporter"
},
- Download this repository, run these syntax below :
$ npm install
$ npm test
{path}/mochachaiapitestingtypescript/mochawesome-report/mochawesome.html
- https://mochajs.org/
- https://visionmedia.github.io/superagent/
- https://www.chaijs.com/
- https://www.chaijs.com/plugins/chai-http/
- https://extendsclass.com/json-schema-validator.html
- https://codebeautify.org/jsonviewer
Log
> mochachaiapitestingtypescript@1.0.0 test /home/okta/Documents/GitHub/mochachaiapitestingtypescript
> mocha -r ts-node/register src/specs/**/*.ts --reporter mochawesome --timeout 10000
Create employee record
✓ TC04 - Create Employee Record (4213ms)
Get All Employee Data
✓ TC01 - Get All Employee Data (1243ms)
Get Single Employee Data
✓ TC02 - Get One Employee Data (1174ms)
✓ TC03 - Get One Employee Data With Invalid id (1017ms)
4 passing (8s)
[mochawesome] Report JSON saved to /home/okta/Documents/GitHub/mochachaiapitestingtypescript/mochawesome-report/mochawesome.json
[mochawesome] Report HTML saved to /home/okta/Documents/GitHub/mochachaiapitestingtypescript/mochawesome-report/mochawesome.html