When using mockery to mock modules while testing, don't forget to disable it after the tests are done:
after(function () {
mockery.disable();
});When you run the tests from the command line it's fine, you just run the tests and then the command line gets control. If you run the tests inside gulp however, gulp gets control afterwards, and gulp needs to use module methods like define/require. Since these methods are overridden by Mockery they won't work as expertect and you will get cryptic errors like:
[13:31:14] TypeError: Cannot read property 'defaultEncoding' of undefined