CodeFarmer
CodeFarmer

Reputation: 2706

How to test JQuery fail callback?

This is jquery function:

$.get("/url", function(){

   //success
}).fail(function(){
  //fail     <---- how to make code go in there.
});

Problem is how to let program goes into .fail block, I use .Net MVC, However, set break point in Controller doesn't trigger a timeout exception then leads to fail callback.

Don't know how people test this.

Should I start looking at some tools ?

Upvotes: 8

Views: 349

Answers (2)

Jagadish Dharanikota
Jagadish Dharanikota

Reputation: 263

Use an invalid endpoint URL. You should get 404 - not found http status code error.

Upvotes: 0

Serj Sagan
Serj Sagan

Reputation: 30247

Put this in your Controller method:

return new HttpStatusCodeResult(HttpStatusCode.NotFound);

Upvotes: 1

Related Questions