views:

673

answers:

3
+8  Q: 

JQuery Mocking

I am looking for a mature framework that can do Javascript mocking, especially on AJAX and JSON area.

Is there any existing mocking framework for Javascript ( and/ or JQuery) that you are used and can recommend?

Edit: I have evaluated jqmock and jqunit. It seems that it's the only framework that can do basic library mocking and stubbing, but it can't do AJAX call.

+11  A: 

Here are some links that might help you:

amok (claims to have ajax support)

fakequery

QUnit

JSMock

qMock

jqunit + jqmock


Other javascript testing "frameworks"

jqunit

Jack

YUI Test

JSSpec

jitter
added amok *reach 15 character limit*
jitter
+2  A: 

I prefer modular code. Modular code is easy to mock!

var function fetchAjaxData(){
  // Perform ajax request.
  // Call 'update' with the data in question.
}

var update = function(ajaxData){
  // do things with ajaxData
}

With this kind of code, all you need to do is to call the 'update' function to mock a ajax request.

August Lilleaas