Using Sinon to mock Ajax responses

Now, it is time to tackle the three tests that we have ignored. They are expecting actual responses from our service. Right now, our service is completely empty. Keep in mind, those tests were written to be unit tests and we need to protect them from the changes in the response that the real endpoint will experience over time. For that reason, we are going to, finally, introduce Sinon.

We will use Sinon to return the results from our mock API instead of the real API. This will allow us to continue to use the work we have already put into the mock API.

After we have our existing tests covered, we are going to introduce integration tests by using Sinon to mock the back-end server. Using Sinon in that way will allow us to test-drive our fetch based speaker service.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.143.153