Skip to content

Instantly share code, notes, and snippets.

@dutzi
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save dutzi/0277e4b9c57a99639b3e to your computer and use it in GitHub Desktop.

Select an option

Save dutzi/0277e4b9c57a99639b3e to your computer and use it in GitHub Desktop.
Don't forget to disable `mockery`

Here's something I learned the hard way...

When using mockery to mock modules while testing, don't forget to disable it after the tests are done:

after(function () {
	mockery.disable();
});
Why is it so important?

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment