My component subscribes to an Observable in a Service, which is populated via an Ngrx selector, generalized here for brevity:
export class MyService {
signInFalied$: Observable<boolean>;
constructor(
private store: Store<MyAppState>,
) {
this.signInFailed$ = this.store.select(mySelectors.signInFailed);
}
}
My component has conditional content based on this state value, and I would like to test that the correct content is displayed. In my test, I'm providing a mock for the service as such:
describe('My Test', () => {
let spectator: SpectatorHost<MyComponent>;
const createHost = createHostComponentFactory({
component: MyComponent,
declarations: [MyComponent],
providers: [
...,
mockProvider(MyService, {
signInFailed$: cold('x', { x: null }),
...
}),
],
imports: [...]
});
});
When I run tests, I get:
Error: No test scheduler initialized
Through searches I have tried setting my compile target to ES5
I'm also using the latest version of jasmine-marbles at this time: 0.6.0
What am I doing wrong?
I think I have faced this issue before. I am not sure about
angular-spectator
but forjasmine
on the firstbeforeEach
I callinitTestScheduler
andaddMatchers
.Something like this: