Closed blipboard closed 12 years ago
I've committed changes that fix the filename issue on recent versions of Node, but in a way that allows Mockery 1.1.2 to work on both current and older versions.
Ways to register multiple allowable in a single call are in the works, as are some other changes that should be useful for functional / integration tests.
A number of people are having trouble using mockery because previous tests leave modules in the node module cache which may contain references to mocked modules. The presence of these mocked modules then breaks subsequent tests.
https://groups.google.com/forum/#!topic/nodejs/AioYD0tlmjo/discussion
There is currently no way to clear the node cache due to a bug in mockery.js. It turns out that the line:
is the problem. Instead of returning the resolved filename, the [1] returns the second character of the returned filename, and not the actual filename, as the rest of the logic implies it should. As a result, modules which were registeredAllowable with unhook=true are never removed from the node module cache.
I have fixed this bug, and added a couple of functions that I find helpful for integration testing, where many modules are included. In this case, it's tedious to registerAllowable all the modules that get included during a load. For this purpose, I added:
I've added documentation for these functions in the README.
Thanks for making mockery! We're finding it really useful.
Cheers,
Aneil