答案 0 :(得分:0)
在beforeEach函数中,在提供程序内部将useClass
替换为useValue
。
beforeEach(async(() => {
service = jasmine.createSpyObj('ContactService', ['getContacts']);
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
declarations: [CityComponent],
providers: [{provide: ContactService, useValue: service}]
})
.compileComponents();
}));