Jasmine matchers for Sinon.JS

I have written a small plugin for the Jasmine BDD JavaScript testing framework to allow for better integration with the Sinon.JS spying, stubbing and mocking library.

Using Sinon.JS with Jasmine means you end up writing slightly unhelpful expectations. Here is a simple spec involving a Sinon spy:


The jasmine-sinon plugin creates custom matchers for Jasmine, so that you can do this instead:


This means that your specs read better, but you also get better failure output from the Jasmine spec runner. Instead of:

Expected false to be truthy.

the output is:

Expected Function to have been called with 'foo'.

The plugin is at version 0.1, and needs some further testing. It is also missing any exception matchers. Please fork at will.

Jasmine-sinon plugin on Github.

Enjoy the article?

Get my future articles on front end development, automated testing and happy teams delivered straight to your inbox

Hate manual browser testing?

Want to test your website across different browsers and devices, but hate the slog of checking by hand after every change?

Get my step-by-step guide to automating cross-browser design testing.