-
Notifications
You must be signed in to change notification settings - Fork 27k
Closed
Labels
area: routerarea: testingIssues related to Angular testing features, such as TestBedIssues related to Angular testing features, such as TestBedfeatureIssue that requests a new featureIssue that requests a new featurefreq3: 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'] },
}]),
],
});vickblau, martinmcwhorter, DHainzl, mixalbl4-127, el-hult and 41 more
Metadata
Metadata
Assignees
Labels
area: routerarea: testingIssues related to Angular testing features, such as TestBedIssues related to Angular testing features, such as TestBedfeatureIssue that requests a new featureIssue that requests a new featurefreq3: highhotlist: google