diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index af47d4b3e7e2..3ad263ce81b8 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -3057,7 +3057,7 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) { this.stack = e.stack + '\n' + errorForStack.stack; if (e.stackArray) this.stackArray = e.stackArray; }; - ErrorAddingDeclarationLocationStack.prototype.toString = Error.prototype.toString; + ErrorAddingDeclarationLocationStack.prototype = Error.prototype; window.inject = angular.mock.inject = function() { var blockFns = Array.prototype.slice.call(arguments, 0); diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index 04d5493f2659..d1e3b87298b9 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -631,7 +631,6 @@ describe('ngMock', function() { inject(); // Trigger the tests in `module` }); - }); @@ -985,6 +984,22 @@ describe('ngMock', function() { }); } }); + + describe('ErrorAddingDeclarationLocationStack', function() { + it('should be caught by Jasmine\'s `toThrowError()`', function() { + function throwErrorAddingDeclarationStack() { + module(function($provide) { + $provide.factory('badFactory', function() { + throw new Error('BadFactoryError'); + }); + }); + + inject(function(badFactory) {}); + } + + expect(throwErrorAddingDeclarationStack).toThrowError(/BadFactoryError/); + }); + }); }); }); @@ -2616,8 +2631,10 @@ describe('make sure that we can create an injector outside of tests', function() angular.injector([function($injector) {}]); }); + describe('`afterEach` clean-up', function() { describe('`$rootElement`', function() { + describe('undecorated', function() { var prevRootElement; var prevCleanDataSpy; @@ -2780,6 +2797,7 @@ describe('`afterEach` clean-up', function() { }); }); + describe('sharedInjector', function() { // this is of a bit tricky feature to test as we hit angular's own testing // mechanisms (e.g around jQuery cache checking), as ngMock augments the very @@ -3037,5 +3055,4 @@ describe('sharedInjector', function() { if (typeof fn !== "function") throw Error("not fn", fn); sdescribe.current.afterEach.push(fn); } - });