DEV Community

S. M. Ahad Ali Chowdhury
S. M. Ahad Ali Chowdhury

Posted on • Updated on

testing node js api using mocha and chai

testing node js api using chai and mocha

first following the step for installing mocha and chai

  1. npm install mocha --save-dev
  2. npm install chai --save-dev
  3. npm install chai-http --save-dev
  4. go to the package.json file and write in scripts "test": "mocha"
  5. then create a folder and create a file (like api.js) and code your testing
  6. Write npm test in terminal for testing the test

for better understanding you can try below link for understanding how mocha and chai work and how we write testing code for test our application------

https://www.digitalocean.com/community/tutorials/test-a-node-restful-api-with-mocha-and-chai

Discussion (0)