{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/9815","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/9815/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/9815/comments","events_url":"https://api.github.com/repos/angular/angular/issues/9815/events","html_url":"https://github.com/angular/angular/issues/9815","id":163816879,"number":9815,"title":"bug(testing) Unable to do async-initialization in beforeEach-hook","user":{"login":"choeller","id":423277,"avatar_url":"https://avatars.githubusercontent.com/u/423277?v=3","gravatar_id":"","url":"https://api.github.com/users/choeller","html_url":"https://github.com/choeller","followers_url":"https://api.github.com/users/choeller/followers","following_url":"https://api.github.com/users/choeller/following{/other_user}","gists_url":"https://api.github.com/users/choeller/gists{/gist_id}","starred_url":"https://api.github.com/users/choeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/choeller/subscriptions","organizations_url":"https://api.github.com/users/choeller/orgs","repos_url":"https://api.github.com/users/choeller/repos","events_url":"https://api.github.com/users/choeller/events{/privacy}","received_events_url":"https://api.github.com/users/choeller/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-07-05T10:16:02Z","updated_at":"2016-07-06T14:32:13Z","closed_at":null,"body":"**I'm submitting a ...**  (check one with \"x\")\r\n```\r\n[x] bug report\r\n[ ] feature request\r\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n```\r\n\r\n**Current behavior**\r\n\r\nIn my tests I use the beforeEach-Hook to create the component-fixture. This worked in the past but with the latest changes I'm unable to get that working again. Trying to do it like this:\r\n\r\n```ts\r\n  beforeEach(async(inject([TestComponentBuilder, TaskService],\r\n    (_tcb:TestComponentBuilder, _taskService:TaskService) => {\r\n      return _tcb\r\n        .overrideDirective(TaskListComponent, RouterLinkWithHref, DummyRouterLink)\r\n        .overrideDirective(TaskItemComponent, RouterLinkWithHref, DummyRouterLink)\r\n        .createAsync(TaskListComponent)\r\n        .then(_fixture => {\r\n          fixture = _fixture;\r\n          console.log(\"fixture\", fixture);\r\n        });\r\n    })));\r\n```\r\ndoesn't wait for the component to be created (the fixture is printed but after the test fails)\r\n\r\nTrying to use (done) callback from jasmine also doesn't work. In this case the inject-function is not called/executed at all:\r\n\r\n\r\n```ts\r\n  beforeEach((done) => {\r\n    inject([TestComponentBuilder, TaskService],\r\n      (_tcb:TestComponentBuilder, _taskService:TaskService) => {\r\n        taskService = _taskService;\r\n        _tcb\r\n          .overrideDirective(TaskListComponent, RouterLinkWithHref, DummyRouterLink)\r\n          .overrideDirective(TaskItemComponent, RouterLinkWithHref, DummyRouterLink)\r\n          .createAsync(TaskListComponent)\r\n          .then(_fixture => {\r\n            fixture = _fixture;\r\n            console.log(\"fixture\", fixture);\r\n            done();\r\n          });\r\n      })\r\n  });\r\n```\r\nthis leads to:\r\n\r\n```Chrome 48.0.2564 (Linux 0.0.0) TaskList Component should call deleteTask when clicking the trash-bin FAILED\r\n\tError: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.```\r\n\r\n\r\n**Expected/desired behavior**\r\n\r\nbeforeEach callback should wait for returned promises / should be able to work with done-function\r\n\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\n\r\nbeing able to initialize the component under test in beforeEach-Hook\r\n\r\n**Please tell us about your environment:**\r\n\r\n* **Angular version:** 2.0.0-rc.4\r\n \r\n* **Browser:** [all ] \r\n \r\n* **Language:** [TS] \r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/230790207","html_url":"https://github.com/angular/angular/issues/9815#issuecomment-230790207","issue_url":"https://api.github.com/repos/angular/angular/issues/9815","id":230790207,"user":{"login":"cexbrayat","id":411874,"avatar_url":"https://avatars.githubusercontent.com/u/411874?v=3","gravatar_id":"","url":"https://api.github.com/users/cexbrayat","html_url":"https://github.com/cexbrayat","followers_url":"https://api.github.com/users/cexbrayat/followers","following_url":"https://api.github.com/users/cexbrayat/following{/other_user}","gists_url":"https://api.github.com/users/cexbrayat/gists{/gist_id}","starred_url":"https://api.github.com/users/cexbrayat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cexbrayat/subscriptions","organizations_url":"https://api.github.com/users/cexbrayat/orgs","repos_url":"https://api.github.com/users/cexbrayat/repos","events_url":"https://api.github.com/users/cexbrayat/events{/privacy}","received_events_url":"https://api.github.com/users/cexbrayat/received_events","type":"User","site_admin":false},"created_at":"2016-07-06T14:32:12Z","updated_at":"2016-07-06T14:32:12Z","body":"@choeller Using `async`, pretty much as in your first example. I migrated the 300 unit tests of my ebook to rc.4, and then a few hundreds in other projects,all clear using `async` if I comment `system-polyfill` in karma conf..."}}
{"actor":{"display_login":"cexbrayat"}}