Jquery 1.5 mock ajax

In jquery 1.5, what approach is recommended for mocking ajax requests? Is using ajax extension extensions used? http://api.jquery.com/extending-ajax/#Transports

+3
source share
3 answers

Have you tried the $.ajax with update 1.5 and found out if you can call .resolve on jqXHR .

Until you delete the .promise only .promise object with a delay, you can fake ajax request termination.

An alternative, you can always just mock the node.js server.

Anywhere where you can connect and get the jqXHR object, you can call .resolve on it using mock parameters.

+1
source

I have a similar question:

How to check jquery and ajax calls using JsTestDriver?

And I found solutions, others may be better, but it works with our JsTestDriver tests.

0
source

I created a mock for jQuery AJAX and I used the three extension points provided by jQuery 1.5+ (prefitler, transport and converters). Check this.

https://github.com/fredyang/ajaxMock

for detailed use, please check the test case, all test cases have been submitted, and they are just a living document on how to use it.

Here is the url of the test case

https://github.com/fredyang/ajaxMock/blob/master/test/test.js

Here is the link that launches the test case

http://code.semanticsworks.com/ajaxMock/test/index.html

and here is the layout link

http://code.semanticsworks.com/ajaxMock/src/ajaxMock.js

0
source

Source: https://habr.com/ru/post/892898/


All Articles