December 2017
Beginner
372 pages
10h 32m
English
By now, we know that the primary purpose of the beforeEach function is to provide us with the place where we write the code that we want to be executed after every test. This allows us to make sure that each test is performed in isolation, and not affected by the result of the previous step.
In our Trello service test, the beforeEach function would mock the HTTP object and create an instance of the Trello service class, as shown in the following code:
beforeEach(()=>{ mockHTTP = jasmine.createSpyObj('mockHTTP',['get']); trelloService = new TrelloService(mockHTTP); });
The first line of the beforeEach function is interesting.
To be able to mock the HTTP object, we would need a way to also mock the methods inside the ...
Read now
Unlock full access