Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 566
Graviton Avatar asked Jun 21 '09 10:06

Graviton


Video Answer


2 Answers

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

like image 145
jitter Avatar answered Dec 08 '22 09:12

jitter


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.

like image 43
August Lilleaas Avatar answered Dec 08 '22 09:12

August Lilleaas