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
11
votes
3 answers

QUnit: How to test ajax call without modifying the ajax call

How can I write a QUnit test for this: function doSomethingWithAjax() { $.ajax({ url: '/GetHelloWorld', success: function(data) { $("#responseFromServer").text(data); }, }); } Mockjax+qunit requires a start() call in the…
Brian Low
  • 11,605
  • 4
  • 58
  • 63
4
votes
1 answer

Dynamic Cascading Dropdown using AJAX

Objective: Based on the example found here. Populating dependent drop-downs with the data parsed in the getData() function using ajax calls. Currently my example is working with static data found in the ajax-mocks.js file, but I am unable to…
Ben Löffel
  • 931
  • 4
  • 12
  • 29
4
votes
1 answer

jquery.mockjax using with Webpack needing shim

Has anyone used mockjax for jasmine unit tests with webpack? I keep getting $.mockjax is undefined. It has something to do with // NOTE: To use Mockjax as a Node module you MUST provide the factory with // a valid version of jQuery and a window…
Craig
  • 55
  • 3
4
votes
1 answer

Mockjax HTTP error code

Is it possible to mock HTTP error codes, and other header information using mockjax? $.mockjax({ url: '/some/webservice', dataType: 'html', responseText: '
Hello there
' }); // Normal ajax request in your application $.ajax({ …
Billy Moon
  • 57,113
  • 24
  • 136
  • 237
4
votes
1 answer

Multiple responses from identical calls in asynch QUnit + Mockjax tests

I'm trying to test some jQuery ajax code using QUnit and Mockjax and have it return different JSON for different tests, like this: $(document).ready(function() { function functionToTest() { return $.getJSON('/echo/json/', { json:…
NickL
  • 1,870
  • 2
  • 15
  • 35
3
votes
1 answer

Ember.js can't mock ajax using jquery-mockjax

I use jquery-mockjax to mock my AJAX request for my tests and after I upgraded my ember from 2.3.0 -> 2.10.0 it no longer works because my service is using Ember.$.ajax() instead of directly $.ajax() any idea how to make mockjax still work with…
GantengX
  • 1,471
  • 2
  • 16
  • 28
3
votes
1 answer

Mockjax use in an angular app

I am new to AngularJS. Can I use mockjax in AngularJS by calling mock end points using $http services method get/post. If not is there a way $http provides a way to create end points and call them? For example The MockService is something like…
Mozak
  • 2,738
  • 4
  • 30
  • 49
3
votes
1 answer

Mockjax via a function and data

In mockjax you can use a function to return a different response according to the request data type, like so: $.mockjax(function(settings) { if ( settings.dataType == 'json' ) { return { dataType: 'json', …
sidonaldson
  • 24,431
  • 10
  • 56
  • 61
3
votes
1 answer

Testing with qunit and mockjax

I am trying to figure out how to test this javascript function aduequately using qunit and mockjax My javascript is set up with the revealing module pattern, im new to unit testing so this is kind of driving me up a wall my.someMethod = function…
Philip Loyer
  • 738
  • 2
  • 7
  • 22
2
votes
2 answers

Can Mockjax handle single IDs Api from Json file

I'm using Mockjax for the first time to mock a Restful API which will return a series of data given an id. Right now i have a json file that has several Items, and i would like to have a function inside Mockjax (or where necessary) to return only…
Carlos Valencia
  • 6,499
  • 2
  • 29
  • 44
2
votes
1 answer

Protractor mocking jQuery ajax

Is it possible to mock an jQuery.ajax request (which gets called because of Kendo UI's Datasource) in an AngularJs app via Protractor? Used Script/Framework etc Protractor jQuery jsdom Mockjax I tried with following script (without the ajax…
Ben jamin
  • 946
  • 1
  • 6
  • 18
2
votes
0 answers

Using mockjax with mocha

I am experimenting with building a very simple API using express and would like to use Mocha for testing. I also want to use jquery-mockjax to mock third-party API calls but not sure how to go about that. I used npm install to install Mocha…
Koes Bong
  • 1,113
  • 3
  • 15
  • 28
2
votes
1 answer

X-editable official example (jsFiddle) doesn't work

I am learning X-editable library and I wonder why one of the examples from the official website is not working. JavaScript $('#username').editable({ type: 'text', url: '/post', pk: 1, title: 'Enter username', ajaxOptions:…
2
votes
1 answer

Jasmine test with jquery-mockjax.js stub

I have a basic jQuery ajax call, which I am mocking the response using jquery.mockjax.js: $(document).ready(function() { $("button.ajax").on("click", getAjaxResult); }); function getAjaxResult() { $.getJSON("/restful/get",…
lawrence
  • 21
  • 2
2
votes
1 answer

Mock rest API call using mockjax

I am using ember-cli to develop an ember application and ember-data with restful API calls to a rails backend. Also using qunit for testing purpose. (https://github.com/appendto/jquery-mockjax for mocking AJAX request) Here am facing issue while…
Swati
  • 842
  • 10
  • 26
1
2 3 4 5