Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sadabnepal/mountebank-supertest-api
service virtualisation using mountebank stub and testing using supertest mocha and chai
https://github.com/sadabnepal/mountebank-supertest-api
api-test chai eslint mocha mochawesome mocks moutebank service-virtualization stub supertest
Last synced: 1 day ago
JSON representation
service virtualisation using mountebank stub and testing using supertest mocha and chai
- Host: GitHub
- URL: https://github.com/sadabnepal/mountebank-supertest-api
- Owner: sadabnepal
- Created: 2024-03-03T12:08:33.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-17T01:51:55.000Z (10 months ago)
- Last Synced: 2024-11-20T15:53:21.605Z (2 months ago)
- Topics: api-test, chai, eslint, mocha, mochawesome, mocks, moutebank, service-virtualization, stub, supertest
- Language: TypeScript
- Homepage:
- Size: 107 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Mountebank Supertest mocha stub and test framework
boilerplate project to showcase virtualization of rest services using mountebank and testing rest api using supertest nodejs library with mocha framework### getting started
```
git clone https://github.com/sadabnepal/mountebank-supertest-api.git
cd mountebank-supertest-api
```### pre-requisite
[![NodeJs](https://img.shields.io/badge/-NodeJS-%23339933?logo=npm)](https://nodejs.org/en/download/)
[![VSCode](https://img.shields.io/badge/-Visual%20Studio%20Code-%233178C6?logo=visual-studio-code)](https://code.visualstudio.com/download)### install packages
```
npm install
```### start stub [ for ENV=local]
```
npm start
```### set env
```
export ENV=local
OR
export ENV=dev
```### base url
```
local: http://localhost:4545/api
dev: https://reqres.in/api
```### run test
```
npm run test
```### stub details
The project is using [mountebank](http://www.mbtest.org) as a service virtualization tool, which provides following endpoints
| http call | endpoint | status code | payload |
|-------------|------------------------|-------------|-----------|
| GET | `/users/` | 200 | N/A |
| GET | `/users?page=` | 200 | N/A |
| POST | `/users` | 201 | `{"name": "sadab", "job": "tester" }` |
| PUT | `/users/` | 200 | `{"name": "saqib", "job": "admin" }` |
| POST | `/register` | 200 | `{"email": "[email protected]", "password": "test@123" }` |
| POST | `/login` | 200 | `{"email": "[email protected]", "password": "test@123" }` |Note: default response will be empty object `{}` with response code: `404`
### learning references:
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### TODO
- [x] stub setup
- [x] simple stub
- [x] convert stub to dynamic
- [x] setup test framework
- [x] create simple test
- [x] add different env stage test support
- [x] add lint support for quality code
- [x] fix linting error in js files
- [x] fix default stub response error
- [x] add more stubs to replicate all https call
- [x] cover all test scenarios
- [x] create complex advance stubs (register and login)
- [x] document all endpoints in readme