This repository has been archived by the owner. It is now read-only.
Mock your jQuery ajax requests
JavaScript Ruby CoffeeScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Moqueur is a jQuery plugin allowing you to mock your ajax requests so they return the value you wish them to. It's particularly useful when testing your javascript code.

In ruby/rails, with harmony/holygrail, you can then test your javascript in ruby. For an example, you can check moqueur's specs.


If you only wish to use moqueur, you can just pick the file "moqueur.js" and add it wherever you want in your public directory. In your test environment, add this file in your content. Create some mocks and you're ready to go !

Mocking a request

For now, there's not a lot of options. But more are coming ! And if you wish something to be included, feel free to open a ticket.

You can mock an url with the following :

    url: '/test',
    content: "Hello World !"

When whenever you make an ajax request (with jQuery.ajax) to the url /test, no call will really be made and the content returned will be "Hello World".

Example : jQuery.ajax({url: '/test'});

You can also use the success method, which will be appropriately executed.

    url: '/test',
    success: function() {
        return 'Yay, it works !'


If you think Moqueur is great but can be improved, feel free to contribute. To do so, you can :

  • Fork the project
  • Do your changes and commit them to your repository
  • Test your changes. We won't accept any untested contributions (except if they're not testable).
  • Create an issue with a link to your commits.

And that's it! We'll soon take a look at your issue and review your changes.

Author and Credits

Damien MATHIEU :: 42 (AT|CHEZ)