{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.js/issues/13594","labels_url":"https://api.github.com/repos/angular/angular.js/issues/13594/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/13594/comments","events_url":"https://api.github.com/repos/angular/angular.js/issues/13594/events","html_url":"https://github.com/angular/angular.js/issues/13594","id":123147681,"number":13594,"title":"ngMock window.inject() does not add inject() call location info to errors thrown from repeated inject() callback calls","user":{"login":"jurko-gospodnetic","id":3112833,"avatar_url":"https://avatars.githubusercontent.com/u/3112833?v=3","gravatar_id":"","url":"https://api.github.com/users/jurko-gospodnetic","html_url":"https://github.com/jurko-gospodnetic","followers_url":"https://api.github.com/users/jurko-gospodnetic/followers","following_url":"https://api.github.com/users/jurko-gospodnetic/following{/other_user}","gists_url":"https://api.github.com/users/jurko-gospodnetic/gists{/gist_id}","starred_url":"https://api.github.com/users/jurko-gospodnetic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jurko-gospodnetic/subscriptions","organizations_url":"https://api.github.com/users/jurko-gospodnetic/orgs","repos_url":"https://api.github.com/users/jurko-gospodnetic/repos","events_url":"https://api.github.com/users/jurko-gospodnetic/events{/privacy}","received_events_url":"https://api.github.com/users/jurko-gospodnetic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-20T09:22:32Z","updated_at":"2015-12-20T22:35:43Z","closed_at":null,"body":"**Overview of the Issue**\r\n`ngMock` `window.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.\r\n\r\n**Motivation for or Use Case**\r\nHere's a typical scenario where a callback passed to `ngMock`'s `window.inject()` function gets called multiple times in a single test suite:\r\n```\r\ndescribe('I\\'m a little tea pot', function() {\r\n  beforeEach(inject(function() {\r\n    throw new Error();\r\n  }));\r\n  it('first test spec', function () {});\r\n  it('second test spec', function () {});\r\n});\r\n```\r\nHere 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.\r\n\r\n**Angular Version(s)**\r\n- reproduced using angular `1.4.8` & `master` versions\r\n\r\n**Browsers and Operating System**\r\n- reproducible using any browser supporting JavaScript error stack information, e.g. Chrome, Firefox & Opera, IE10+ & PhantomJS (though when using IE & PhantomJS browsers we have other related problems until issue #13591 is fixed)\r\n- reproduced using `Ubuntu 15.10`, but should not be OS specific\r\n\r\n**Reproduce the Error**\r\nJust run the use case presented in the **Motivation for or Use Case** section above.\r\n\r\n**Suggest a Fix**\r\n- don't clear the `errorForStack` information after the first call to the `window.inject()` callback"},"comment":{"url":"https://api.github.com/repos/angular/angular.js/issues/comments/166159819","html_url":"https://github.com/angular/angular.js/issues/13594#issuecomment-166159819","issue_url":"https://api.github.com/repos/angular/angular.js/issues/13594","id":166159819,"user":{"login":"jurko-gospodnetic","id":3112833,"avatar_url":"https://avatars.githubusercontent.com/u/3112833?v=3","gravatar_id":"","url":"https://api.github.com/users/jurko-gospodnetic","html_url":"https://github.com/jurko-gospodnetic","followers_url":"https://api.github.com/users/jurko-gospodnetic/followers","following_url":"https://api.github.com/users/jurko-gospodnetic/following{/other_user}","gists_url":"https://api.github.com/users/jurko-gospodnetic/gists{/gist_id}","starred_url":"https://api.github.com/users/jurko-gospodnetic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jurko-gospodnetic/subscriptions","organizations_url":"https://api.github.com/users/jurko-gospodnetic/orgs","repos_url":"https://api.github.com/users/jurko-gospodnetic/repos","events_url":"https://api.github.com/users/jurko-gospodnetic/events{/privacy}","received_events_url":"https://api.github.com/users/jurko-gospodnetic/received_events","type":"User","site_admin":false},"created_at":"2015-12-20T22:35:43Z","updated_at":"2015-12-20T22:35:43Z","body":"Pull request #13597 is a fix for this issue for the `1.4.x` branch.\r\nPull request #13598 is a fix for this issue for the `master` branch."}}