Failed: Cannot read property 'queryParams' of null at
I'm assuming it's because I have the following in ngOnInit():
ngOnInit() {
this.route.queryParams.subscribe(async params => {
this.userInfo = await JSON.parse(params['user_info']);
});
So far I've tried constructing my unit test with the following:
describe('AddItineraryPage', () => {
let component: AddItineraryPage;
let fixture: ComponentFixture<AddItineraryPage>;
let routeStub;
beforeEach(async(() => {
routeStub = null;
TestBed.configureTestingModule({
declarations: [ AddItineraryPage ],
imports: [IonicModule.forRoot(), FormsModule, ReactiveFormsModule, RouterTestingModule],
providers: [
{provide: ActivatedRoute, useValue: routeStub}
]
}).compileComponents();
fixture = TestBed.createComponent(AddItineraryPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
routeStub.queryParams = {
displayName: '',
dateOfBirth: '',
email: '',
photos: [],
location: '',
bio: '',
intDestination: [],
userId: ''};
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(component).toBeTruthy();
});
});
});