Nerd For Tech
Published in

Nerd For Tech

Show some love for Mocha api tests! Testing #2


Let’s set up

npm run test command
first example test
util.ts file responsible to set up tests infrastructure
create.js file acting like a Factory design pattern

The tests

all tests cases for /api/items resource
First GET /api/items test
GET /api/items second test
GET /api/items last test case
GET /api/items/:id tests
POST /api/items
PUT /api/items/:id part 1
PUT /api/items/:id part 2
DELETE /api/items/:id

Final touches

test:watch script
reporter dot
no reporter flag, or default reporter
reporter nyan

Final words



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store