Skip to content

Commit 0816eca

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 338c152 commit 0816eca

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

0 commit comments

Comments
 (0)