diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 6bbb7a651db7..ce0dfdfe035c 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -2480,6 +2480,7 @@ if (window.jasmine || window.mocha) { if (injector) { injector.get('$rootElement').off(); + injector.get('$rootScope').$destroy(); } // clean up jquery's fragment cache diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index 806b37036dcf..5d2732a66eb2 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -1650,6 +1650,21 @@ describe('ngMock', function() { }); + describe('$rootScope', function() { + var destroyed = false; + + it('should destroy $rootScope after each test', inject(function($rootScope) { + $rootScope.$on('$destroy', function() { + destroyed = true; + }); + })); + + it('should have destroyed the $rootScope from the previous test', function() { + expect(destroyed).toBe(true); + }); + }); + + describe('$rootScopeDecorator', function() { describe('$countChildScopes', function() {