In my Angular 4 component I have something like:
constructor(private route: ActivatedRoute) {
}
ngOnInit() {
this.myId
If using route.snapshot.paramMap.get( 'uuid' ) instead:
import { ActivatedRoute, convertToParamMap } from '@angular/router';
{
provide: ActivatedRoute, useValue:
{ snapshot: { paramMap: convertToParamMap( { 'uuid': '99-88-77' } ) } }
}
Ok, I've found how to mock ActivatedRoute snapshot in the simple way. Something like this works for me:
providers: [MyComponent, {
provide: ActivatedRoute,
useValue: {snapshot: {params: {'myId': '123'}}}
}
Thanks :)