-
Notifications
You must be signed in to change notification settings - Fork 27.1k
RouterTestingModule should provide a way to set up snapshot data #15779
Copy link
Copy link
Closed
Labels
area: routerarea: testingIssues related to Angular testing features, such as TestBedIssues related to Angular testing features, such as TestBedfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfreq3: highhotlist: google
Milestone
Description
Feature Request.
It would be nice to be able to set up route data and snapshots from the RouterTestingModule. The motivation here is something like a component which uses the route data in its init:
@Component({})
class MyComp {
constructor(private route: ActivatedRoute) {};
ngOnInit() {
this.pizza = this.route.snapshot.data['pizza'];
}
}Currently, this can be tested by adding a provider to the TestBed to mock out ActivatedRoute, however it feels like something you should be able to do from the RouterTestingModule. Perhaps something like:
TestBed.configureTestingModule({
imports: [
RouterTestingModule.withRoutes([{
path: '', // something to denote that this is the one that should be used?
data: { pizzaToppings: ['mozzarella', 'onion', 'basil'] },
}]),
],
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: routerarea: testingIssues related to Angular testing features, such as TestBedIssues related to Angular testing features, such as TestBedfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfreq3: highhotlist: google