1
karma + jsamine을 사용하여 테스트 한 후에 이러한 종류의 오류가 발생했습니다. 서비스 : ContactService에서 사용 가능한 언어를 반환해야합니다. FAILED 오류 : ContactService의 모든 매개 변수를 해결할 수 없습니다 (?). 나는 이것에 무슨 결론을 내리지 못합니다. 오류 : ContactService의 모든 매개 변수를 해결할 수 없습니다. (?)
다음
import {inject,TestBed,async} from "@angular/core/testing";
import {ContactService} from "./ContactService.component"
import {HttpModule} from "@angular/http";
describe('Service: ContactService',() => {
let service;
beforeEach(() => TestBed.configureTestingModule({
imports:[HttpModule],
providers: [ ContactService ]
}));
beforeEach(inject([ContactService], s => {
service = s;
}));
it('should return available languages',async(() => {
service.get().subscribe(x=> {
expect(x).toContain('en');
expect(x).toContain('es');
expect(x).toContain('fr');
expect(x.length).toEqual(3);
});
}));
});
import {Http} from "@angular/http";
const CONTACT_URL = "./pages/contacts.json"
export class ContactService{
constructor(private http:Http) { }
public getContactById(id: number) {
// return this.get(CONTACT_URL, { id: id });
}
get(){
return this.http.get(CONTACT_URL).map(response => response.json())
}
}
시도'Injectable' 또는'@Inject (HTTP)'으로하고 tsconfig을 확인 – yurzui