Skip to content

Add global before/after hook to your Mocha test environment.

License

Notifications You must be signed in to change notification settings

ayecue/mocha-prepare-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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

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

About

Add global before/after hook to your Mocha test environment.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published