Questions tagged [mockjax]

jQuery Mockjax provides request/response mocking for ajax requests with jQuery and provides all standard behaviors in the request/response flow.

jQuery Mockjax provides request/response mocking for ajax requests with jQuery and provides all standard behaviors in the request/response flow.

github page

73 questions
2
votes
1 answer

Calling a post mockjax service with jquery $.post not returning value

I am attempting to call a Mockjax 'post' endpoint through jQuery $.post method as below service.js $.mockjax({ url: '/api/callfor/data', type: 'post', responseTime: 1000, contentType: 'text/json', dataType: 'json', …
Mozak
  • 2,738
  • 4
  • 30
  • 49
2
votes
1 answer

Problems with mocking jsonp requests using mockjax in qunit

I'd like to use mockjax with qunit but can't get it to work. Here is a simple test I tried: http://jsfiddle.net/shapeshifta/3YNB2/ asyncTest('Response returns jsonp', function() { $.mockjax({ url:…
shapeshifta
  • 300
  • 5
  • 16
1
vote
1 answer

Testing inline callback function with JsTestDriver and Mockjax

I want to test the following AJAX function my.var = true; my.method = function() { $.getJSON('/path/to/', function(data){ my.var = false; }); } How should I use JsTestDriver to test that my.var has changed?…
jerkan
  • 685
  • 2
  • 10
  • 28
1
vote
0 answers

jquery autocomplete with mockjax

I am new to mackjax, pls tell me how to use the given below code for data coming from a url instead of local data i.e. countries array. The code is working fine for local array in the file i.e. countries{} but how to make it work for the data coming…
Krishna Singh
  • 33
  • 1
  • 6
1
vote
1 answer

Qunit ajax async calls with mockajax

I am trying to construct a Qunit test to test an ajax post call. I am using mockajax to mock the call. However, I can't get the test to work with the asynchronous call. Here is my source code: source.js: ajaxFunc = function(element){ $.post({ …
user3520634
  • 301
  • 3
  • 9
1
vote
1 answer

Using Mockjax in QUnit?

I see this example in Mockjax docs: $.mockjax({ url: "/rest", data: function ( json ) { assert.deepEqual( JSON.parse(json), expected ); // QUnit example. return true; } }); But I am not sure how should I use it with QUnit testing…
Vlad
  • 2,739
  • 7
  • 49
  • 100
1
vote
1 answer

How to use jQuery plus plugins and dependent libraries with Webpack

I am trying to understand how to port an existing set of code to Webpack. Here's my scenario: I'm using jQuery with Bootstrap, KendoUI, Mockjax, some jQuery plugin-ish libraries (e.g. bootbox, jQuery BlockUI). Previously (using requireJS), I was…
1
vote
1 answer

mockjax equivalent in jest or plain JS Unit Test Library (eg. Karma Jasmine )

Greetings want a very basic unit test for some of the ajax requests of my application. http://jsfiddle.net/Orbifold/sqdzzvey/ I want to know what you use to mock endpoints in your applications like it is done here: $.mockjax({ url:…
partizanos
  • 1,064
  • 12
  • 22
1
vote
1 answer

Deferred jQuery AJAX request does not run done() callback function

I have setup a simple demo using jQuery Deferred object with AJAX request to simulate how my app is doing it. My issue is, ever since I switched over from the older non-deferred method, I cannot get a success callback. Only the fail() callback is…
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
1
vote
1 answer

Test ajax call with qunit and mockjax

I'm trying to test that an ajax call. I need to test that the correct url is called, with the correct data and result. Starting off with this test which fails. The error I get is "Expected: saved, Actual: ". Function in my knockout viewmodel…
newbie_86
  • 4,520
  • 17
  • 58
  • 89
1
vote
2 answers

responseTime is not working in Mockjax

I need to simulate a long responseTime. My Moockjax is working – it delivers the right mock data. But my ajax call is done in the second i load the page, even if i set the responseTime to 20 seconds. Do you have an idea? I reduced my test page to…
DerZyklop
  • 3,672
  • 2
  • 19
  • 27
1
vote
2 answers

Can I call done without passing done into my real implementation?

I am writing some jasmine tests and using mockjax to mock out my ajax calls. I know jasmine requires some extra work to get it to work asynchronously but i dont like my solution. I am passing in 'done' into my real implementation and then calling…
4imble
  • 13,979
  • 15
  • 70
  • 125
1
vote
1 answer

How to make mockjax return an ember-data object

Given that I have the Ember-data model (this is CoffeeScript): Person = DS.Model.extend firstName: DS.attr("string") lastName: DS.attr("string") Or as JavaScript: Person = DS.Model.extend({ firstName: DS.attr("string"), lastName:…
northben
  • 5,448
  • 4
  • 35
  • 47
1
vote
1 answer

How to verify that mockjax has been called

I have a method that when called, makes a HTTP request to the server, and does not care about what happens after. The response is not parsed, and it does not change its state after sending the request or receiving the response. Now I wish to test…
bguiz
  • 27,371
  • 47
  • 154
  • 243
1
vote
1 answer

Mockjax not intercepting async form submission

I'm using qUnit and mockjax to try and handle a simple async form submission but for some reason, the async POST seems to pass through mockjax. test 'RuleModal closes the modal on a successful form submission event', -> $.mockjax dataType:…