This repository was 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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:
I have ensured the existing tests still pass and the new functionality has been tested in exactly the same way.