{"action":"created","issue":{"url":"https://api.github.com/repos/angular/material2/issues/1913","repository_url":"https://api.github.com/repos/angular/material2","labels_url":"https://api.github.com/repos/angular/material2/issues/1913/labels{/name}","comments_url":"https://api.github.com/repos/angular/material2/issues/1913/comments","events_url":"https://api.github.com/repos/angular/material2/issues/1913/events","html_url":"https://github.com/angular/material2/issues/1913","id":190067265,"number":1913,"title":"[md-menu][bug] Tests crash in MdMenu.ngOnDestroy","user":{"login":"pchiquet","id":1631021,"avatar_url":"https://avatars.githubusercontent.com/u/1631021?v=3","gravatar_id":"","url":"https://api.github.com/users/pchiquet","html_url":"https://github.com/pchiquet","followers_url":"https://api.github.com/users/pchiquet/followers","following_url":"https://api.github.com/users/pchiquet/following{/other_user}","gists_url":"https://api.github.com/users/pchiquet/gists{/gist_id}","starred_url":"https://api.github.com/users/pchiquet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pchiquet/subscriptions","organizations_url":"https://api.github.com/users/pchiquet/orgs","repos_url":"https://api.github.com/users/pchiquet/repos","events_url":"https://api.github.com/users/pchiquet/events{/privacy}","received_events_url":"https://api.github.com/users/pchiquet/received_events","type":"User","site_admin":false},"labels":[{"id":311421490,"url":"https://api.github.com/repos/angular/material2/labels/P2:%20required","name":"P2: required","color":"eb6420","default":false}],"state":"open","locked":false,"assignee":{"login":"kara","id":3871688,"avatar_url":"https://avatars.githubusercontent.com/u/3871688?v=3","gravatar_id":"","url":"https://api.github.com/users/kara","html_url":"https://github.com/kara","followers_url":"https://api.github.com/users/kara/followers","following_url":"https://api.github.com/users/kara/following{/other_user}","gists_url":"https://api.github.com/users/kara/gists{/gist_id}","starred_url":"https://api.github.com/users/kara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kara/subscriptions","organizations_url":"https://api.github.com/users/kara/orgs","repos_url":"https://api.github.com/users/kara/repos","events_url":"https://api.github.com/users/kara/events{/privacy}","received_events_url":"https://api.github.com/users/kara/received_events","type":"User","site_admin":false},"assignees":[{"login":"kara","id":3871688,"avatar_url":"https://avatars.githubusercontent.com/u/3871688?v=3","gravatar_id":"","url":"https://api.github.com/users/kara","html_url":"https://github.com/kara","followers_url":"https://api.github.com/users/kara/followers","following_url":"https://api.github.com/users/kara/following{/other_user}","gists_url":"https://api.github.com/users/kara/gists{/gist_id}","starred_url":"https://api.github.com/users/kara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kara/subscriptions","organizations_url":"https://api.github.com/users/kara/orgs","repos_url":"https://api.github.com/users/kara/repos","events_url":"https://api.github.com/users/kara/events{/privacy}","received_events_url":"https://api.github.com/users/kara/received_events","type":"User","site_admin":false}],"milestone":null,"comments":14,"created_at":"2016-11-17T14:47:50Z","updated_at":"2017-02-08T14:51:05Z","closed_at":null,"body":"#### Bug, feature request, or proposal:\r\nBug\r\n\r\n#### What is the expected behavior?\r\nThe test should work\r\n\r\n#### What is the current behavior?\r\nTests on a component that uses MdMenu crash in  MdMenu.ngOnDestroy, with error \"**Cannot read property 'unsubscribe' of undefined**\"\r\n\r\n```Error: Error in ./AppComponent class AppComponent - inline template:12:2 caused by: Cannot read property 'unsubscribe' of undefined\r\n        TypeError: Cannot read property 'unsubscribe' of undefined\r\n            at MdMenu.ngOnDestroy (webpack:///C:/Users/User/git/training/material2-menu-test/~/@angular/material/menu/menu-directive.js:44:0 <- src/test.ts:41822:30)\r\n            at Wrapper_MdMenu.ngOnDestroy (/MdMenuModule/MdMenu/wrapper.ngfactory.js:14:16)\r\n            at CompiledTemplate.proxyViewClass.View_AppComponent0.destroyInternal (/DynamicTestModule/AppComponent/component.ngfactory.js:265:21)\r\n            at CompiledTemplate.proxyViewClass.AppView.destroy (webpack:///C:/Users/User/git/training/material2-menu-test/~/@angular/core/src/linker/view.js:143:0 <- src/test.ts:55639:14)\r\n            at CompiledTemplate.proxyViewClass.DebugAppView.destroy (webpack:///C:/Users/User/git/training/material2-menu-test/~/@angular/core/src/linker/view.js:368:0 <- src/test.ts:55864:38)\r\n            at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.destroyInternal (/DynamicTestModule/AppComponent/host.ngfactory.js:33:19)\r\n            at CompiledTemplate.proxyViewClass.AppView.destroy (webpack:///C:/Users/User/git/training/material2-menu-test/~/@angular/core/src/linker/view.js:143:0 <- src/test.ts:55639:14)\r\n            at CompiledTemplate.proxyViewClass.DebugAppView.destroy (webpack:///C:/Users/User/git/training/material2-menu-test/~/@angular/core/src/linker/view.js:368:0 <- src/test.ts:55864:38)\r\n            at CompiledTemplate.proxyViewClass.AppView.detachAndDestroy (webpack:///C:/Users/User/git/training/material2-menu-test/~/@angular/core/src/linker/view.js:130:0 <- src/test.ts:55626:14)\r\n            at ComponentRef_.destroy (webpack:///C:/Users/User/git/training/material2-menu-test/~/@angular/core/src/linker/component_factory.js:121:51 <- src/test.ts:25170:70)\r\n```\r\n\r\n#### What are the steps to reproduce?\r\n\r\nFrom this github repo: https://github.com/pchiquet/material2-menu-test\r\n- git clone https://github.com/pchiquet/material2-menu-test  \r\n- npm install  \r\n- ng test\r\n\r\nor manually:\r\n- `ng new test-project`\r\n- Setup Material2\r\n- Add a md-menu in src/app/app.component.html\r\n- launch test: `ng test`\r\n\r\n#### What is the use-case or motivation for changing an existing behavior?\r\nTesting apps with md-menu\r\n\r\n#### Which versions of Angular, Material, OS, browsers are affected?\r\n\r\n- angular-cli 1.0.0-beta.20 (angular 2.1)\r\n- angular/material 2.0.0-alpha.10\r\n\r\n#### Is there anything else we should know?\r\ngithub repo to reproduce the issue : https://github.com/pchiquet/material2-menu-test\r\n"},"comment":{"url":"https://api.github.com/repos/angular/material2/issues/comments/278349210","html_url":"https://github.com/angular/material2/issues/1913#issuecomment-278349210","issue_url":"https://api.github.com/repos/angular/material2/issues/1913","id":278349210,"user":{"login":"Almar","id":637761,"avatar_url":"https://avatars.githubusercontent.com/u/637761?v=3","gravatar_id":"","url":"https://api.github.com/users/Almar","html_url":"https://github.com/Almar","followers_url":"https://api.github.com/users/Almar/followers","following_url":"https://api.github.com/users/Almar/following{/other_user}","gists_url":"https://api.github.com/users/Almar/gists{/gist_id}","starred_url":"https://api.github.com/users/Almar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Almar/subscriptions","organizations_url":"https://api.github.com/users/Almar/orgs","repos_url":"https://api.github.com/users/Almar/repos","events_url":"https://api.github.com/users/Almar/events{/privacy}","received_events_url":"https://api.github.com/users/Almar/received_events","type":"User","site_admin":false},"created_at":"2017-02-08T14:51:05Z","updated_at":"2017-02-08T14:51:05Z","body":"@Headcult 's solution works for me too. It took me a while to fix my problem though. I had about 60 failing tests because I was using a material component (md-select in my case) in my AppComponent. It took only one ```fixture.detectChanges``` (in app.component.spec.ts, where I call ```TestBed.createComponent(AppComponent);```) to fix all failing tests."}}
{"actor":{"display_login":"Almar"}}