Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 612607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:54:43+00:00 2026-05-13T17:54:43+00:00

I am using Jack as JavaScript mocking library. http://github.com/keronsen/jack . I am also using

  • 0

I am using Jack as JavaScript mocking library. http://github.com/keronsen/jack . I am also using qunit.

I have following AJAX call in my javascript code which I am tring to write test for.

$.ajax({
    url: $('#advance_search_form').attr('action'),
    type: 'post',
    dataType: 'json',
    data: parameterizedData,
    success: function(json) {
        APP.actOnResult.successCallback(json);
    }
});

Following code is working.

jack(function() {
    jack.expect('$.ajax').exactly('1 time');
}

However I want to test if all the arguments are properly submitted. I tried following but did not work.

jack.expect('$.ajax').exactly('1 time').whereArgument(0).is(function(){

var args = arguments;
ok(‘http://localhost:3000/users‘, args.url, ‘url should be valid’);
// similary test for many keys of object
});

I want to get hold of arguments so that I could perform a battery of test.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:54:43+00:00Added an answer on May 13, 2026 at 5:54 pm

    Two approaches:

    Use .hasProperties():

    jack.expect('$.ajax').once()
        .whereArgument(0).hasProperties({
             'type': 'post',
             'url': 'http://localhost:3000/users'
        });
    

    … or capture the arguments and make qunit assertions:

    var ajaxArgs;
    jack.expect('$.ajax').once().mock(function() { ajaxArgs = arguments[0]; });
    // ... the code that triggers .ajax()
    equals('http://localhost:3000/users', ajaxArgs.url);
    

    The first version uses more of the Jack API (that deserves better documentation), and is more readable, IMO.

    The latter version will give you much better error reporting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following node module because I would like to prevent XSS: https://github.com/chriso/node-validator
I have been using the code in http://opensebj.blogspot.com/2009/04/naudio-tutorial-5-recording-audio.html to record audio. Basically this code:
I'm using swank-clojure from https://github.com/technomancy/swank-clojure . I'd like to run clojure-jack-in automatically when a
I'm currently trying to mock the following method using Jack. The code example is
I have an application using JACK MIDI under Linux. It works perfectly on 32
I am trying to run a jack-knife using Plyr. I have a large dataset
Parsing HTML / JS codes to get info using PHP. www.asos.com/Asos/Little-Asos-Union-Jack-T-Shirt/Prod/pgeproduct.aspx?iid=1273626 Take a look
I'm using SerializableAttribute to write an object jack to disk. The object has a
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I have tried using a combination of both of these two previous questions Question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.