Skip to content

Commit 48f222c

Browse files
test(ngMock window.inject): error stack trace on repeated injection calls
Injection function throwing an Error should update the thrown Error's stack trace information with the window.inject() call location information, on its initial as well as repeated invocations.
1 parent 4b0763f commit 48f222c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/ngMock/angular-mocksSpec.js

+22
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,28 @@ describe('ngMock', function() {
981981
}
982982
});
983983
});
984+
985+
describe('when called outside of test spec context', function() {
986+
var injectingCall = testInjectCaller();
987+
988+
// regression test for issue #13594
989+
// regression test for issue #13591 when run on IE10+ or PhantomJS
990+
it('should update thrown Error stack when repeated inject callback invocations fail', function() {
991+
injectingCall.setThrow(false);
992+
injectingCall(); // initial call that will not throw
993+
injectingCall.setThrow(true);
994+
try {
995+
injectingCall(); // non-initial call, but first failing one
996+
} catch (e) {
997+
expect(e.stack).toMatch('testInjectCaller');
998+
}
999+
try {
1000+
injectingCall(); // repeated failing call
1001+
} catch (e) {
1002+
expect(e.stack).toMatch('testInjectCaller');
1003+
}
1004+
});
1005+
});
9841006
});
9851007
}
9861008
});

0 commit comments

Comments
 (0)