boilerplate project to showcase virtualization of rest services using mountebank and testing rest api using supertest nodejs library with mocha framework
git clone https://github.com/sadabnepal/mountebank-supertest-api.git
cd mountebank-supertest-api
npm install
npm start
export ENV=local
OR
export ENV=dev
local: http://localhost:4545/api
dev: https://reqres.in/api
npm run test
The project is using mountebank as a service virtualization tool, which provides following endpoints
http call | endpoint | status code | payload |
---|---|---|---|
GET | /users/<id> |
200 | N/A |
GET | /users?page=<number> |
200 | N/A |
POST | /users |
201 | {"name": "sadab", "job": "tester" } |
PUT | /users/<id> |
200 | {"name": "saqib", "job": "admin" } |
POST | /register |
200 | {"email": "test@test.com", "password": "test@123" } |
POST | /login |
200 | {"email": "test@test.com", "password": "test@123" } |
Note: default response will be empty object {}
with response code: 404
mountebank: http://www.mbtest.org
supertest: http://visionmedia.github
mocha: https://ricostacruz.com/mocha/
mocharc: https://github.com/mochajs/mocha/tree/master/example/config
chai: https://www.chaijs.com
report: https://github.com/adamgruber/mochawesome
eslint: https://eslint.org/docs/latest/use/getting-started
vscode settings: https://code.visualstudio.com/docs/getstarted/settings
- stub setup
- simple stub
- convert stub to dynamic
- setup test framework
- create simple test
- add different env stage test support
- add lint support for quality code
- fix linting error in js files
- fix default stub response error
- add more stubs to replicate all https call
- cover all test scenarios
- create complex advance stubs (register and login)
- document all endpoints in readme