Alright, how do I mock the store in an Jasmine/Karma test of an Angular controller so that I do not see this error? Stealing one-for-one from here, you will want to put this just inside the describe:
let storeMock;
You will want to put this just inside the foreach:
storeMock = {
dispatch: jasmine.createSpy("dispatch"),
pipe: jasmine.createSpy("pipe").and.returnValue(from([{
requestTimeout: 5000,
}]))
};
I ended up adding select: function(input:any):Observable<User> { to storeMock for my own uses/needs to accommodate a selector predictably. You'll need a provider the likes of { provide: Store, useValue: storeMock } in the providers third and finally to get all of this to work. The imports up top must include:
import { from } from 'rxjs';
import { Store } from '@ngrx/store';
No comments:
Post a Comment