Closed JanEggers closed 7 years ago
Are you using ngMock? We dealt with this issue in our tests by mocking $localStorage
and $sessionStorage
.
module('ngStorage', ($provide) => {
function mockStorage() {
this.$apply = this.$default = this.$reset = this.$supported = this.$sync = () => {};
}
$provide.service('$sessionStorage', mockStorage);
$provide.service('$localStorage', mockStorage);
});
We're using jasmine and put that in a global beforeEach
. Depending on your usage you may need to flesh the mocked functions out more.
I also stumbled on this issue. These two event handlers should be unregistered on $rootScope.$on('$destroy')
.
$window.addEventListener('storage', function(event) {
// ...
});
$window.addEventListener('beforeunload', function() {
// ...
});
hi i have a close eye on memory and currently i have found a memory leak related to ngstorage.
ngstorage keeps my rootscopes alive while unittesting.
should not be relevant for live apps but is there a way to fix that?