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

Commit f0dc534

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 bd739b0 commit f0dc534

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/ngMock/angular-mocksSpec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,28 @@ describe('ngMock', function() {
986986
}
987987
});
988988
});
989+
990+
describe('when called outside of test spec context', function() {
991+
var injectingCall = testInjectCaller();
992+
993+
// regression test for issue #13594
994+
// regression test for issue #13591 when run on IE10+ or PhantomJS
995+
it('should update thrown Error stack when repeated inject callback invocations fail', function() {
996+
injectingCall.setThrow(false);
997+
injectingCall(); // initial call that will not throw
998+
injectingCall.setThrow(true);
999+
try {
1000+
injectingCall(); // non-initial call, but first failing one
1001+
} catch (e) {
1002+
expect(e.stack).toMatch('testInjectCaller');
1003+
}
1004+
try {
1005+
injectingCall(); // repeated failing call
1006+
} catch (e) {
1007+
expect(e.stack).toMatch('testInjectCaller');
1008+
}
1009+
});
1010+
});
9891011
});
9901012
}
9911013
});

0 commit comments

Comments
 (0)