Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tag: 0.0.1
Fetching contributors…

Cannot retrieve contributors at this time

57 lines (37 sloc) 2.008 kB



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)

Jump to Line
Something went wrong with that request. Please try again.