10. Test EventListComponent
In this section we will add snapshot tests with Jest that are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
1. Add a snapshot test
In this test we will first populate the attendees manually by assigning the variable to a hardcoded value in the test. We then run fixture.detectChanges
which triggers Angular to run change detection and update the HTML template. Last we do a expectation using the .toMatchSnapshot
Jest matcher.
Add a snapshot test to the EditListComponent.
The
toMatchSnapshot
matcher might cause an error with the compiler not knowing this symbol, but do not worry it will still work.
src/app/event/components/event-list/event-list.component.spec.ts
StackBlitz Link
Last updated