Unit testing jQuery getJSON function errors with the fail method, using Jasmine and Karma
问题 I've written a unit test for a function that calls the jQuery getJSON method. The only thing that I'm testing is that it is called with the expected URL. My unit test uses a Jasmine Spy to mock the API call. However, when I run my unit tests I get this error: 1) should make a request to the expected URL when running on localhost test module getDataFromApi function TypeError: Cannot read property 'fail' of undefined In my unit test I've created a Jasmine Spy, which returns the done and fail