March 2017
Intermediate to advanced
118 pages
2h 1m
English
Everything in Angular is testable, and the router isn't an exception. In this chapter we will look at three ways to test routable components: isolated tests, shallow tests, and integration tests.
It is often useful to test complex components without rendering them. To see how it can be done, let's write a test for the following component:
@Component({moduleId: module.id, templateUrl: 'compose.html'}) class ComposeCmp { form = new FormGroup({ title: new FormControl('', Validators.required), body: new FormControl('') }); constructor(private route: ActivatedRoute, private currentTime: CurrentTime, private actions: Actions) {} onSubmit() { const routerStateRoot = this.route.snapshot.root; const conversationRoute ...Read now
Unlock full access