{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/1036","labels_url":"https://api.github.com/repos/angular/angular/issues/1036/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/1036/comments","events_url":"https://api.github.com/repos/angular/angular/issues/1036/events","html_url":"https://github.com/angular/angular/issues/1036","id":63317405,"number":1036,"title":"Component testing in isolation","user":{"login":"rkirov","id":95713,"avatar_url":"https://avatars.githubusercontent.com/u/95713?v=3","gravatar_id":"","url":"https://api.github.com/users/rkirov","html_url":"https://github.com/rkirov","followers_url":"https://api.github.com/users/rkirov/followers","following_url":"https://api.github.com/users/rkirov/following{/other_user}","gists_url":"https://api.github.com/users/rkirov/gists{/gist_id}","starred_url":"https://api.github.com/users/rkirov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkirov/subscriptions","organizations_url":"https://api.github.com/users/rkirov/orgs","repos_url":"https://api.github.com/users/rkirov/repos","events_url":"https://api.github.com/users/rkirov/events{/privacy}","received_events_url":"https://api.github.com/users/rkirov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-20T22:01:05Z","updated_at":"2015-03-30T20:57:38Z","closed_at":null,"body":"As components are the basic building blocks of angular 2 applications, it is important to have a solid testing story for them. If the user has a component:\r\n```\r\n@Component\r\n@Template({directives: [B, C]})\r\nclass A\r\n```\r\nit is important to be able to mock or stub out `B` and `C` while testing `A` and its template. Since the template annotation is static, we need a new mechanism of dynamically rewiring the template directives list.\r\n\r\nTo support this I suggest the following API for `TestBed`\r\n```\r\n// Most mocks don't need @Template (can we skip it?)\r\n@Component\r\n@Template\r\nclass MockB() {\r\n\r\n}\r\n\r\nit('...', inject([TemplateModifier], (tm) => {\r\n  tm.for(A).mockDirectives([MockB, MockC]));\r\n  var rootEl = TestBed.compiler('<a></a>');\r\n}));\r\n```\r\n\r\nFurther tools for generating `mockB` and setting expectations on it can be provided."},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/87829452","html_url":"https://github.com/angular/angular/issues/1036#issuecomment-87829452","issue_url":"https://api.github.com/repos/angular/angular/issues/1036","id":87829452,"user":{"login":"rkirov","id":95713,"avatar_url":"https://avatars.githubusercontent.com/u/95713?v=3","gravatar_id":"","url":"https://api.github.com/users/rkirov","html_url":"https://github.com/rkirov","followers_url":"https://api.github.com/users/rkirov/followers","following_url":"https://api.github.com/users/rkirov/following{/other_user}","gists_url":"https://api.github.com/users/rkirov/gists{/gist_id}","starred_url":"https://api.github.com/users/rkirov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkirov/subscriptions","organizations_url":"https://api.github.com/users/rkirov/orgs","repos_url":"https://api.github.com/users/rkirov/repos","events_url":"https://api.github.com/users/rkirov/events{/privacy}","received_events_url":"https://api.github.com/users/rkirov/received_events","type":"User","site_admin":false},"created_at":"2015-03-30T20:57:38Z","updated_at":"2015-03-30T20:57:38Z","body":"@vicb mentions this capability in his doc https://docs.google.com/document/d/1qFfHwYCOLpLuTap_l6TCEaU4I0C-pVFVbTl2o4-XbUo/edit#\r\n\r\nunder `TB.overrideTemplateDirectives(componentType, fromDirective, toDirective);`"}}