{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.js/issues/10238","labels_url":"https://api.github.com/repos/angular/angular.js/issues/10238/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/10238/comments","events_url":"https://api.github.com/repos/angular/angular.js/issues/10238/events","html_url":"https://github.com/angular/angular.js/issues/10238","id":50201204,"number":10238,"title":"Jasmine 2.1 beforeAll/afterAll methods cause errors","user":{"login":"chesleybrown","id":492166,"avatar_url":"https://avatars.githubusercontent.com/u/492166?v=3","gravatar_id":"","url":"https://api.github.com/users/chesleybrown","html_url":"https://github.com/chesleybrown","followers_url":"https://api.github.com/users/chesleybrown/followers","following_url":"https://api.github.com/users/chesleybrown/following{/other_user}","gists_url":"https://api.github.com/users/chesleybrown/gists{/gist_id}","starred_url":"https://api.github.com/users/chesleybrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chesleybrown/subscriptions","organizations_url":"https://api.github.com/users/chesleybrown/orgs","repos_url":"https://api.github.com/users/chesleybrown/repos","events_url":"https://api.github.com/users/chesleybrown/events{/privacy}","received_events_url":"https://api.github.com/users/chesleybrown/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular.js/labels/component:%20ngMock","name":"component: ngMock","color":"bfd4f2"},{"url":"https://api.github.com/repos/angular/angular.js/labels/needs:%20investigation","name":"needs: investigation","color":"444444"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/angular/angular.js/milestones/27","html_url":"https://github.com/angular/angular.js/milestones/Backlog","labels_url":"https://api.github.com/repos/angular/angular.js/milestones/27/labels","id":489171,"number":27,"title":"Backlog","description":"Holds the backlog of issues and pull requests that have been triaged.\r\n\r\nBefore assigning items to this milestone they should be labelled, at the very least with the correct \"type\" label (i.e. \"issue\", \"pr\", \"bug\", \"regression\", \"chore\", \"docs\", etc).  Preferably you should also check for duplicate issues/PRs, note CLA status and assign \"complexity\" and \"impact\" labels too.","creator":{"login":"IgorMinar","id":216296,"avatar_url":"https://avatars.githubusercontent.com/u/216296?v=3","gravatar_id":"","url":"https://api.github.com/users/IgorMinar","html_url":"https://github.com/IgorMinar","followers_url":"https://api.github.com/users/IgorMinar/followers","following_url":"https://api.github.com/users/IgorMinar/following{/other_user}","gists_url":"https://api.github.com/users/IgorMinar/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorMinar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorMinar/subscriptions","organizations_url":"https://api.github.com/users/IgorMinar/orgs","repos_url":"https://api.github.com/users/IgorMinar/repos","events_url":"https://api.github.com/users/IgorMinar/events{/privacy}","received_events_url":"https://api.github.com/users/IgorMinar/received_events","type":"User","site_admin":false},"open_issues":680,"closed_issues":1016,"state":"open","created_at":"2013-11-18T23:30:35Z","updated_at":"2015-10-30T21:09:29Z","due_on":null,"closed_at":null},"comments":17,"created_at":"2014-11-26T16:45:28Z","updated_at":"2015-10-31T21:12:22Z","closed_at":"2015-01-31T13:59:55Z","body":"Jasmine has released `beforeAll` and `afterAll` methods with [2.1](http://jasmine.github.io/2.1/introduction.html) which allow executing a `before` function only once for all the following specs. Angular mocks doesn't seem to play nice with this concept.\r\n\r\nWhen using `beforeAll` or `afterAll` methods, I encounter the following errors.\r\n\r\n```\r\nTypeError: 'null' is not an object (evaluating 'currentSpec.$modules')\r\n\t    at workFn (/Users/chesleybrown/Sites/bln-web/app/components/angular-mocks/angular-mocks.js:2323)\r\n\t    at /Users/chesleybrown/Sites/bln-web/node_modules/karma-jasmine/lib/boot.js:71\r\n\t    at /Users/chesleybrown/Sites/bln-web/node_modules/karma-jasmine/lib/adapter.js:174\r\n\t    at http://localhost:9876/karma.js:185\r\n\t    at http://localhost:9876/context.html:168\r\n\tTypeError: 'null' is not an object (evaluating 'currentSpec.$modules')\r\n\t    at workFn (/Users/chesleybrown/Sites/bln-web/app/components/angular-mocks/angular-mocks.js:2323)\r\n\t    at /Users/chesleybrown/Sites/bln-web/node_modules/karma-jasmine/lib/boot.js:71\r\n\t    at /Users/chesleybrown/Sites/bln-web/node_modules/karma-jasmine/lib/adapter.js:174\r\n\t    at http://localhost:9876/karma.js:185\r\n\t    at http://localhost:9876/context.html:168\r\n\tExpected { 0: HTMLNode, length: 1, prevObject: { 0: HTMLNode, length: 1 }, context: undefined, selector: '.loading-indicator' } to have class 'ng-hide'.\r\n\tError: Expected { 0: HTMLNode, length: 1, prevObject: { 0: HTMLNode, length: 1 }, context: undefined, selector: '.loading-indicator' } to have class 'ng-hide'.\r\n\t    at /Users/chesleybrown/Sites/bln-web/test/directives/about-product.directive.spec.js:40\r\n\t    at /Users/chesleybrown/Sites/bln-web/node_modules/karma-jasmine/lib/boot.js:71\r\n\t    at /Users/chesleybrown/Sites/bln-web/node_modules/karma-jasmine/lib/adapter.js:174\r\n\t    at http://localhost:9876/karma.js:185\r\n\t    at http://localhost:9876/context.html:168\r\n```"},"comment":{"url":"https://api.github.com/repos/angular/angular.js/issues/comments/152773531","html_url":"https://github.com/angular/angular.js/issues/10238#issuecomment-152773531","issue_url":"https://api.github.com/repos/angular/angular.js/issues/10238","id":152773531,"user":{"login":"lgalfaso","id":391394,"avatar_url":"https://avatars.githubusercontent.com/u/391394?v=3","gravatar_id":"","url":"https://api.github.com/users/lgalfaso","html_url":"https://github.com/lgalfaso","followers_url":"https://api.github.com/users/lgalfaso/followers","following_url":"https://api.github.com/users/lgalfaso/following{/other_user}","gists_url":"https://api.github.com/users/lgalfaso/gists{/gist_id}","starred_url":"https://api.github.com/users/lgalfaso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lgalfaso/subscriptions","organizations_url":"https://api.github.com/users/lgalfaso/orgs","repos_url":"https://api.github.com/users/lgalfaso/repos","events_url":"https://api.github.com/users/lgalfaso/events{/privacy}","received_events_url":"https://api.github.com/users/lgalfaso/received_events","type":"User","site_admin":false},"created_at":"2015-10-31T21:12:22Z","updated_at":"2015-10-31T21:12:22Z","body":"@timruffles I am reading your comment on the proposal and I am not sure how you are proposing this to work. Let me write down what my understanding on your proposal is, and if this is not correct, please write the comprehensive idea.\r\n\r\nWhen there is a `beforeAll` that makes use of `$injector` then all the tests in the `describe` context that `beforeAll` is, will share a unique `$injector`. If there is a global `beforeAll` that makes use of `$injector`, then all the tests share this unique `$injector`.\r\n\r\nEg.\r\n```js\r\ndescribe('X', function() {\r\n  // Here, each test has its own $injector.\r\n  it('X1', inject(function(...) {}));\r\n  it('X2', inject(function(...) {}));\r\n  it('X3', inject(function(...) {}));\r\n});\r\n\r\ndescribe('Y', function() {\r\n  // Here, all test share the same $injector.\r\n  beforeAll(inject(function(...) {}));\r\n\r\n  it('Y1', inject(function(...) {}));\r\n  it('Y2', inject(function(...) {}));\r\n  it('Y3', inject(function(...) {}));\r\n});\r\n```\r\n"}}