"cache already exists" error when unit testing with angular-mocks
Closed this issue · 1 comments
henrahmagix commented
Since this uses CacheFactory that keeps caches = {}
in memory outside of angular, caches persist across unit tests using angular + angular-mocks + karma. This means every test suite that uses CacheFactory
must destroy the cache after every spec, like this:
afterEach(function () {
myCacheThatMustBeInjected.destroy();
});
To make this simpler, the caches object can be reset when the root scope is destroyed, since that is only likely to happen in angular-mocks. Or there may be another method particular to angular-mocks that can be checked.
Will submit a pull-request soon =)
henrahmagix commented
👍