Как прокомментировали другие, начиная с Angular 6, который использует Rxjs6, вам придется импортировать from
из 'rxjs' и использовать его напрямую, не делая Observable.from
Измените вашу реализацию на следующую:
import { TodosComponent } from './todos.component';
import { TodoService } from './todo.service';
import { Observable, from } from 'rxjs';
describe('TodosComponent', () => {
let component: TodosComponent;
let service: TodoService;
beforeEach(() => {
service = new TodoService(null);
component = new TodosComponent(service);
});
it('should set todo property with the item returned from', () => {
const todos = [1, 2, 3];
const data = [{
id: 1,
title: 'a'
},
{
id: 2,
title: 'b'
},
{
id: 3,
title: 'c'
}
];
spyOn(service, 'getTodos').and.callFake(() => {
return from([data]);
});
component.ngOnInit();
expect(component.todos.length).toBe(todos);
});
});