https://github.com/osukaa/mountebank-test
Testing mountebank as local dependency and in process
https://github.com/osukaa/mountebank-test
Last synced: 6 months ago
JSON representation
Testing mountebank as local dependency and in process
- Host: GitHub
- URL: https://github.com/osukaa/mountebank-test
- Owner: osukaa
- License: mit
- Created: 2020-05-20T04:47:52.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T20:22:22.000Z (over 3 years ago)
- Last Synced: 2025-02-07T11:52:46.901Z (over 1 year ago)
- Language: JavaScript
- Size: 751 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mountebank-test
Testing mountebank as local dependency and in process
Trying to run [`mountebank`](http://www.mbtest.org/) as an in-process mock library for node.js tests.
## Setup
1. `server.js` - starts a server
2. `index.js` - setups a hapi server
3. `test.js` - ava tests against mountebank
4. `imposter.js` - fluent api for creating an imposter in the mountebank server
5. `imposters.ejs` - mountebank config file loaded through a flag in the CLI
## running `npm test`
Running `npm test` will start a mountebank instance as default, building on the example from the [mountebank book](https://www.manning.com/books/testing-microservices-with-mountebank).
```
https://github.com/bbyars/mountebank-in-action/blob/master/ch09/webFacadeService/serviceTest/test.js
```
## running `npm run mb`
This will start a mountebank instance as per standard procedure, will use `imposters.ejs` through the flag `--configfile`.
> This will run mountebank in a separate process.
You can then open another terminal and run `npm start` and try doing a curl against `/testing` endpoint
```
$ curl /testing
```
and will get a response back
```json
{
"data": {
"products": [
{
"id": "id-1",
"name": "name-1",
"description": "description-1"
}
]
},
"headers": {
"content-type": "application/json",
"connection": "close",
"date": "Wed, 20 May 2020 05:49:59 GMT",
"transfer-encoding": "chunked"
}
}
```