Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 563ca46

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 1c238a1 commit 563ca46

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
@@ -1001,6 +1001,28 @@ describe('ngMock', function() {
10011001
}
10021002
});
10031003
});
1004+
1005+
describe('when called outside of test spec context', function() {
1006+
var injectingCall = testInjectCaller();
1007+
1008+
// regression test for issue #13594
1009+
// regression test for issue #13591 when run on IE10+ or PhantomJS
1010+
it('should update thrown Error stack when repeated inject callback invocations fail', function() {
1011+
injectingCall.setThrow(false);
1012+
injectingCall(); // initial call that will not throw
1013+
injectingCall.setThrow(true);
1014+
try {
1015+
injectingCall(); // non-initial call, but first failing one
1016+
} catch (e) {
1017+
expect(e.stack).toMatch('testInjectCaller');
1018+
}
1019+
try {
1020+
injectingCall(); // repeated failing call
1021+
} catch (e) {
1022+
expect(e.stack).toMatch('testInjectCaller');
1023+
}
1024+
});
1025+
});
10041026
});
10051027
}
10061028
});

0 commit comments

Comments
 (0)