spyquery

Fake jQuery...

SpyQuery

Emulates jQuery as sinon spies, so you can test code that uses jQuery on the server or in the browser.

Nodejs:

npm install spyquery

Browser Global $:

<script src="spyquery.js"></script>
var SpyQuery = require('spyquery')
var $ = new SpyQuery()
> $('.foo').html()
> {}
> $.fn.html.callCount
> 1

You are able to check any of the attributes of a sinon spy.

var $
describe(function() {
  beforeEach(function(done) {
    $ = new SpyQuery()
    done()
  }
  
  it('should call hide once', function(done) {
    someFunctionWhereHideIsUsed()
    assert($.fn.hide.calledOnce, '$.hide() was called more than once')
    done()
  }
})