Verifying the response by mocking the server response using Jasmine spy

The next it function that we want to write tests the response from the server. Since we do not want to perform the actual API calls in the test method, we use mock data. We will use the spy function with the callFake strategy (this strategy is provided by the Jasmine framework) to perform testing.

Another thing to note in this example is that we have used the Lightning:button component, which is in the Lightning namespace, and hence it is currently not supported in the LTS service to simulate the click event. However, we can work around this by creating an aura:method that calls the function that is invoked on a button click. 

To help us with our testing, we add the following ...

Get Learning Salesforce Lightning Application Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.