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.

Join my daily mailing list

I write about front-end engineering leadership every weekday.

Sign up now and get my Front-End Engineering Responsibilities Laundry List PDF for free.

You'll get regular emails about front-end development. Unsubscribe at any time.

Share this article