node package manager


karma-sinon-expect ================


for Karma

This package wrap sinon.assert API to expect.

Install the module via npm

$ npm install --save-dev karma-sinon-expect

Use sinon and expect from karma-sinon-expect package

global.expect = require('karma-sinon-expect').expect;

Use custom version of sinon and expect

global.expect = require('karma-sinon-expect').use(require('sinon'), require('expect.js'));

This Karma plugin requires Karma ~0.10.0

Add sinon-expect to the frameworks key in your Karma configuration:

module.exports = function(config) {
    frameworks: ['mocha', 'sinon-expect'],

Install the module via bower

$ bower install sinon-expect
<script src="bower_components/expect/expect.js" type="text/javascript"></script>
<script src="bower_components/sinonjs/sinon.js" type="text/javascript"></script>
<script src="bower_components/sinon-expect/sinon-expect.js" type="text/javascript"></script>

Sinon and expect matchers for Sinon are also available:

describe 'karma tests with sinon'->
  it 'can spy on objects'->
    foo = bar: ->
    sinon.spy foo'bar' 'baz'
    expect( 'baz'

Additional expectation

describe 'tests sinon spy with arguments'->
  it 'expect first argument'->
    foo = bar: ->
    sinon.spy foo'bar' 'baz'
    expect( 'baz'
  it 'expect second argument'->
    foo = bar: ->
    sinon.spy foo'bar' 'baz''foo'
    expect( 'foo'
  it 'expect any argument'->
    foo = bar: ->
    sinon.spy foo'bar' 'baz''foo''bar'
    expect( 'bar'
sinon.assert expect
sinon.assert.calledOnce(spy) expect(spy)