Enable support for domains in Mocha tests.
npm install mocha-domains --save-dev
Just require the module in your tests and start writing domains in your tests.
Install the module using npm install mocha-domains --save-dev
. Now just require the module to automatically monkey patch any available mocha
instances. With mocha
, you have multiple ways of requiring the module - add --require mocha-domains
to your mocha.opts
or add require('mocha-domains')
inside your main test file.
If you need to monkey patch a different mocha instance you can use the library directly:
var mocha = require('mocha')
var mochaDomains = require('mocha-domains')
mochaDomains(mocha)
The module monkey patches the Runnable.prototype.run
method of mocha
to
enable domains. In contrast to other npm packages, mocha-domains
extends
mocha
at runtime - allowing you to use any compatible mocha version.