jquery - QUnit and a fail JSONP scenario -
I want to check that my web app handles the failure scenario and displays related error messages using Cognit. .
My app makes a JSONP request to get its initial content. I want to check the case where my data source is unavailable at startup. The result of this scenario is an error on the underlying JQuery code, which I believe quinnit is blocking and capturing it as a failed failure, though it is expected behavior.
My app code looks like this:
loadContents () {$ .ajax ({url: initURL, data type: 'jsonp', timeout: timeout, Success: initial performance, error: display error message,}); }
My test case looks like this:
asyncTest ("Invalid initial host", 1, function () {initURL = invalidURL; loadPageContents ( ); Index = $ ("#reer-message-div"). Text (). Indexoff (error message); OK (index> 1, "error message not found");})
< / Pre>When I run my trial, I get an additional argument, which always fails. The message in this argument is: "Error loading script" JSONP with url for GET request.
I think that I am running on this issue because the JSONP callback is never executed, it throws an exception, it is considered as a queenit failure claim.
How can my examination be executed without exception, as a failure?
Update - To clarify, Queen's claim works, though I'm somehow making an extra claim, which always fails.
Thank you!
Knowing the reason that the JSONP call was unsuccessful on the background, this error during the trial To suppress, I had to add the error handler to the document object when the error was expected.
errorNamespace = "error.test" $ (document) .on (errorNamespace, function) {ok (true, "received expected error"); // Error prevent event.stopPropagation (); // remove error handler to allow other errors to flow $ (document) .off (errorNamespace);}); Unfortunately, there is no information in the error event that would help me verify that I got the error caught, which can be a problem.
Comments
Post a Comment