/mochachaiapitestingtypescript

This repository is dedicated to the Indonesia Software Quality Assurance members for online learning material.

Primary LanguageTypeScript

Apache JMeter logo

SOFTWARE TESTING ENTHUSIAST


REST API Testing with Typescript

REST API Testing with Typescript + Mocha + Chai Framework

Precondition

  • Node.js is installed
  • Npm is installed

Generate report

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"
  },

How to run the test

  • Download this repository, run these syntax below :
$ npm install
$ npm test

Test Report Sample

{path}/mochachaiapitestingtypescript/mochawesome-report/mochawesome.html

image

image

References

Testing Log Sample

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