Title: bug(testing) Unable to do async-initialization in beforeEach-hook · Issue #9815 · angular/angular · GitHub
Open Graph Title: bug(testing) Unable to do async-initialization in beforeEach-hook · Issue #9815 · angular/angular
X Title: bug(testing) Unable to do async-initialization in beforeEach-hook · Issue #9815 · angular/angular
Description: I'm submitting a ... (check one with "x") [x] bug report [ ] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question Current be...
Open Graph Description: I'm submitting a ... (check one with "x") [x] bug report [ ] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/ma...
X Description: I'm submitting a ... (check one with "x") [x] bug report [ ] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angula...
Opengraph URL: https://github.com/angular/angular/issues/9815
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug(testing) Unable to do async-initialization in beforeEach-hook","articleBody":"**I'm submitting a ...** (check one with \"x\")\n\n```\n[x] bug report\n[ ] feature request\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\n```\n\n**Current behavior**\n\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:\n\n``` ts\n beforeEach(async(inject([TestComponentBuilder, TaskService],\n (_tcb:TestComponentBuilder, _taskService:TaskService) => {\n return _tcb\n .overrideDirective(TaskListComponent, RouterLinkWithHref, DummyRouterLink)\n .overrideDirective(TaskItemComponent, RouterLinkWithHref, DummyRouterLink)\n .createAsync(TaskListComponent)\n .then(_fixture => {\n fixture = _fixture;\n console.log(\"fixture\", fixture);\n });\n })));\n```\n\ndoesn't wait for the component to be created (the fixture is printed but after the test fails)\n\nTrying to use (done) callback from jasmine also doesn't work. In this case the inject-function is not called/executed at all:\n\n``` ts\n beforeEach((done) => {\n inject([TestComponentBuilder, TaskService],\n (_tcb:TestComponentBuilder, _taskService:TaskService) => {\n taskService = _taskService;\n _tcb\n .overrideDirective(TaskListComponent, RouterLinkWithHref, DummyRouterLink)\n .overrideDirective(TaskItemComponent, RouterLinkWithHref, DummyRouterLink)\n .createAsync(TaskListComponent)\n .then(_fixture => {\n fixture = _fixture;\n console.log(\"fixture\", fixture);\n done();\n });\n })\n });\n```\n\nthis leads to:\n\n`Chrome 48.0.2564 (Linux 0.0.0) TaskList Component should call deleteTask when clicking the trash-bin FAILED\n Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.`\n\n**Expected/desired behavior**\n\nbeforeEach callback should wait for returned promises / should be able to work with done-function\n\n**What is the motivation / use case for changing the behavior?**\n\nbeing able to initialize the component under test in beforeEach-Hook\n\n**Please tell us about your environment:**\n- **Angular version:** 2.0.0-rc.4\n- **Browser:** [all ] \n- **Language:** [TS] \n","author":{"url":"https://github.com/choeller","@type":"Person","name":"choeller"},"datePublished":"2016-07-05T10:16:02Z","url":"https://github.com/angular/angular/issues/9815"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cb151f04-25e6-fef8-bbd9-76641a2dc083 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 838C:2D12EA:5B3C6:7E893:6B056BFE |
| html-safe-nonce | 5b456d45f7d27e6bef93c6c4f71fc0d58cc4bf575e3b7ba9e774a783e428c396 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzhDOjJEMTJFQTo1QjNDNjo3RTg5Mzo2QjA1NkJGRSIsInZpc2l0b3JfaWQiOiIzMDQ3OTMzNjc1MjI5NzY4NzAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9f0d25f19d5b7f0b6c6fbbc68c72716c083e1bfee96c9f31f037383039058ada |
| hovercard-subject-tag | issue:163816879 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/9815/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f811f12a6de76bf7b064030bdaaf0947f7cf6fed604a1327b6b67c6af8944fb4/angular/angular/issues/9815 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f811f12a6de76bf7b064030bdaaf0947f7cf6fed604a1327b6b67c6af8944fb4/angular/angular/issues/9815 |
| og:image:alt | I'm submitting a ... (check one with "x") [x] bug report [ ] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/ma... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | choeller |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9b4256ac5f3e310e7945ef5b71c9cb9e264357b1eb20e91d369ed6502a4c486c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f089e689ad324655ac44bf6cdbc04d976105b374 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width