concept beforeEach in category angular

This is an excerpt from Manning's book Testing Angular Applications.
The part of the tests where you set variables like this is known as the setup. In your setup, you’ll use the
beforeEachmethod to initialize yourcontactvariable every time a test runs. Add a new line and the following code directly beneath thecontactvariable declaration that you previously added:beforeEach(() => { contact = new ContactClass(); });You’ll use the
beforeEachfunctions to set up your tests and toexecute expressions before each one of your tests runs. In this case, you’re setting thecontactvariable to a new instance of theContactClassclass each time you run your test.Now you can write your test. If the test creates an instance of
ContactClasssuccessfully, it will use the class’s constructor to do so. You’ll test this by seeing if thecontactis notnull. Add a new line directly below thebeforeEachmethod that you previously added, and then add the following test case: