Let\'s say I have this
export class QuestionnaireQuestionsComponent {
questions: Question[] = [];
private loading:boolean = true;
constructor(
To customize a mocked ActivatedRoute's data inside each 'it' block, combine what Kevin Black suggested above
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [YourComponent],
imports: [],
providers: [
{
provide: ActivatedRoute, useValue: {
queryParams: of({ id: 'test' })
}
}
]
})
.compileComponents();
}));
and the below code in the it('') block before instantiating a component using fixture.detectChanges()
it('test', fakeAsync(() => {
let activatedRoute: ActivatedRoute = fixture.debugElement.injector.get(ActivatedRoute);
activatedRoute.queryParams = of({ firstName: 'john', lastName: 'smith' });
fixture.detectChanges(); // trigger ngOninit()
tick();
}));