You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Overview of the Issue ngMockwindow.inject() function has some seemingly quick-fix functionality adding the window.inject() call location stack trace information to any errors thrown by the callback passed to the window.inject() call. This however has a bug in that it only adds this information to errors thrown from the first callback invocation, but not for any later ones, while there are typical scenarios when a callback given to it may be invoked multiple times during a single test run.
Motivation for or Use Case
Here's a typical scenario where a callback passed to ngMock's window.inject() function gets called multiple times in a single test suite:
describe('I\'m a little tea pot', function() {
beforeEach(inject(function() {
throw new Error();
}));
it('first test spec', function () {});
it('second test spec', function () {});
});
Here the first test spec's error information will include the window.inject() call location stack trace information, while the second test spec's will not. And if for some reason only the second test spec throws an error, then no window.inject() call location stack trace information will be reported back to the user at all.
Angular Version(s)
reproduced using angular 1.4.8 & master versions
Browsers and Operating System
reproducible using any browser supporting JavaScript error stack information, e.g. Chrome, Firefox & Opera, IE10+ & PhantomJS
reproduced using Ubuntu 15.10, but should not be OS specific
Reproduce the Error
Just run the use case presented in the Motivation for or Use Case section above.
Suggest a Fix
don't clear the errorForStack information after the first call to the window.inject() callback