Skip to content

Commit 2969f55

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 c124a02 commit 2969f55

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
@@ -983,6 +983,28 @@ describe('ngMock', function() {
983983
}
984984
});
985985
});
986+
987+
describe('when called outside of test spec context', function() {
988+
var injectingCall = testInjectCaller();
989+
990+
// regression test for issue #13594
991+
// regression test for issue #13591 when run on IE10+ or PhantomJS
992+
it('should update thrown Error stack when repeated inject callback invocations fail', function() {
993+
injectingCall.setThrow(false);
994+
injectingCall(); // initial call that will not throw
995+
injectingCall.setThrow(true);
996+
try {
997+
injectingCall(); // non-initial call, but first failing one
998+
} catch (e) {
999+
expect(e.stack).toMatch('testInjectCaller');
1000+
}
1001+
try {
1002+
injectingCall(); // repeated failing call
1003+
} catch (e) {
1004+
expect(e.stack).toMatch('testInjectCaller');
1005+
}
1006+
});
1007+
});
9861008
});
9871009
}
9881010
});

0 commit comments

Comments
 (0)