Struggling with setting up tests in my Angular CLI 6 project. Here's a snippet from my testing code:
beforeEach(() => {
spyOn(console, 'info');
TestBed.configureTestingModule({
providers: [
ConsoleLoggerEffects,
provideMockActions(() => actions),
],
});
effects = TestBed.get(ConsoleLoggerEffects);
});
The ConsoleLoggerEffects
class has a single dependency - the Actions
observable:
@Injectable()
export class ConsoleLoggerEffects {
constructor(private actions$: Actions) { }
}
Following the ngrx example, but things aren't working as expected.
When running the tests, I encounter an error message stating
Error: Can't resolve all parameters for ConsoleLoggerEffects: (?)
. Even after adding a console.log
to the factory function inside provideMockActions
, it doesn't seem to be getting called.
Not even manually specifying a provider works:
TestBed.configureTestingModule({
providers: [
ConsoleLoggerEffects,
{ provide: Actions, useValue: new ReplaySubject(1)}
]
});
Any thoughts on what could be causing this issue?