{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/12149","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/12149/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/12149/comments","events_url":"https://api.github.com/repos/angular/angular/issues/12149/events","html_url":"https://github.com/angular/angular/issues/12149","id":181691401,"number":12149,"title":"Testing a service with TestBed and angular 2.0.1","user":{"login":"jcamus","id":3592026,"avatar_url":"https://avatars.githubusercontent.com/u/3592026?v=3","gravatar_id":"","url":"https://api.github.com/users/jcamus","html_url":"https://github.com/jcamus","followers_url":"https://api.github.com/users/jcamus/followers","following_url":"https://api.github.com/users/jcamus/following{/other_user}","gists_url":"https://api.github.com/users/jcamus/gists{/gist_id}","starred_url":"https://api.github.com/users/jcamus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcamus/subscriptions","organizations_url":"https://api.github.com/users/jcamus/orgs","repos_url":"https://api.github.com/users/jcamus/repos","events_url":"https://api.github.com/users/jcamus/events{/privacy}","received_events_url":"https://api.github.com/users/jcamus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-07T15:00:28Z","updated_at":"2016-10-07T16:14:11Z","closed_at":null,"body":"Hello,\r\nI am still fighting with testbed to test my service. Here I have no component to test but just a service with mocks (because this service needs other service via injection). \r\nI have during inject : services are null...\r\n\r\nHere a sample of my non working test :\r\n\r\n```\r\ndescribe('LoginService tests', () => {\r\n\t\tlet service: LoginService;\r\n\t\tlet tokenHandler: HTML5StorageService;\t\r\n\r\n\t\tbeforeEach(() => {\t\t\r\n\r\n\t\t\tconsole.log('*** before each !!');\t\t\t\r\n\r\n\t\t\tTestBed.configureTestingModule({\r\n\t\t\t\tproviders : [\r\n\t\t\t\t\t{provide : LoginService, userValue : LoginService },\t\t\t\t\t\r\n\t\t\t\t\t{provide : XHRBackend, userValue : MockBackend}\t\t\t\t\t\r\n\t\t\t\t]\r\n\t\t\t});\t\t\r\n           });   \r\nit('test1....', async(() => {\r\n\t\t\tTestBed.compileComponents().then(inject([LoginService, XHRBackend], (service : LoginService, mockBackend: MockBackend) => {\r\n\t\t\tconsole.log('**** inject it1 mockBackEnd =' + mockBackend);\r\n\t\t\tconsole.log('**** inject it1 service =' + service);\r\n}));\r\n\t\t}));\r\n\r\nI have following output :\r\n\r\nLOG: '**** inject it1 mockBackEnd =null'\r\nLOG: '**** inject it1 service =null'\r\n\r\nPlease help! Why injection is not working?\r\n\r\n\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/252294893","html_url":"https://github.com/angular/angular/issues/12149#issuecomment-252294893","issue_url":"https://api.github.com/repos/angular/angular/issues/12149","id":252294893,"user":{"login":"gund","id":3644678,"avatar_url":"https://avatars.githubusercontent.com/u/3644678?v=3","gravatar_id":"","url":"https://api.github.com/users/gund","html_url":"https://github.com/gund","followers_url":"https://api.github.com/users/gund/followers","following_url":"https://api.github.com/users/gund/following{/other_user}","gists_url":"https://api.github.com/users/gund/gists{/gist_id}","starred_url":"https://api.github.com/users/gund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gund/subscriptions","organizations_url":"https://api.github.com/users/gund/orgs","repos_url":"https://api.github.com/users/gund/repos","events_url":"https://api.github.com/users/gund/events{/privacy}","received_events_url":"https://api.github.com/users/gund/received_events","type":"User","site_admin":false},"created_at":"2016-10-07T16:14:11Z","updated_at":"2016-10-07T16:14:11Z","body":"Hi,\r\n\r\nProblem probably in your object passed to `TestBed.configureTestingModule()`, and particularly in property `userValue`.  \r\nI think you want `useValue` or even `useClass` in this case will be best match."}}
{"actor":{"display_login":"gund"}}