Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ayecue/mocha-prepare-promise
Add global before/after hook to your Mocha test environment.
https://github.com/ayecue/mocha-prepare-promise
Last synced: 23 days ago
JSON representation
Add global before/after hook to your Mocha test environment.
- Host: GitHub
- URL: https://github.com/ayecue/mocha-prepare-promise
- Owner: ayecue
- License: mit
- Created: 2017-08-04T14:57:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-28T21:43:26.000Z (almost 6 years ago)
- Last Synced: 2024-12-21T23:07:23.267Z (24 days ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mocha-prepare-promise
Add global before/after hook to your Mocha test environment.
This solution is basically just "monkey patching" in mocha.
Original idea from [mocha-prepare](https://github.com/enobufs/mocha-prepare).
## Where to use
- running postgres docker container during your integration tests
- running service docker container during your integration tests
- prepare global data for test
- etc## Installation
```
npm install mocha-prepare-promise --save-dev
```## How to use
### Create file
```javascript
const prepare = require('mocha-prepare-promise');prepare(
//before hook
function () {
//run your async operations like for example starting a docker container
return Promise.resolve();
},
//after hook
function() {
//end all your operations again for example stopping a docker container
return Promise.resolve();
}
);
```### Use --require param of mocha
```
mocha 'files/to/tests.js' --require path/to/your/created/file
```