Basic API operations with Express JS and Unit Testing with mocha

Image source is google image and edited with MS Power Point

Introduction

Project Flow and Description

Initialize Express First

Code snippet to initialize express js
Console log

Create a dummy Data base

Create GET call

Code snippet of GET call
GET request on Postman

Create a new record using POST call

Body for POST request
201 status code once POST call is succeed
GET call. Previously it was 2 records now it is 3 after POST call

Delete an existing record with DELETE

DELETE call through API
Deleted record ID=3
Record ID=3 is deleted now
As record 3 is already deleted hence giving error response with 404 status code

Unit Testing

Unit Test status generated by mocha on console

Conclusion

References

Something about MySelf :)

Sr. SDET by profession with 6+ years of experience in the Software Testing domain. Passionate about learning.