Skip to content
Spy on jQuery, even on the server.
JavaScript
Pull request Compare This branch is 18 commits ahead of tgriesser:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.gitignore
.npmignore
.travis.yml
README.md
package.json
spyquery.js

README.md

SpyQuery

Build Status

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

Installation

Nodejs:

npm install spyquery

Browser Global $:

<script src="spyquery.js"></script>

Usage

Initialization

var SpyQuery = require('spyquery')
var $ = new SpyQuery()

Checking Spies

> $('.foo').html()
> {}
> $.fn.html.callCount
> 1

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

Example Usage In Tests

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()
  }
})
Something went wrong with that request. Please try again.