Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

changed to be able to instancate a new instance with different cache #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MauriceButler
Copy link

I use mockery heavily in modular test structures, ie running tests would require multiple test files which would require mockery many times.

This means that until now a mock that was registered in a previous test file will also be available to other tests. Which is sometime good but not always.

The fact that tests also run asynchronously means that other tests can change the mock at inopportune times...

I have now made it so a new instance of mockery can be created which has its own registered cache so that different tests can be separated from each other cleanly and stop the async code changing my mocks before I want them too.

This means a new instance of mockery can now be instantiated like so:

var Mockery = require('mockery'),
    mockery = new Mockery();

You will see in mockery.js line:334 I have added some code to allow backwards compatibility with the original syntax and functionality so this change will not break existing installations and mockery can still be used as such:

var mockery = require('mockery');

I have ensured the existing tests still pass and the new functionality has been tested in exactly the same way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants