karma-sinon-expect
for Karma
This package wrap sinon.assert API to expect.
Installation
Install the module via npm
$ npm install --save-dev karma-sinon-expect
Nodejs
Use sinon and expect from karma-sinon-expect package
globalexpect = expect;
Use custom version of sinon and expect
globalexpect = ;
Karma
This Karma plugin requires Karma ~0.10.0
Add sinon-expect
to the frameworks
key in your Karma configuration:
module { config;}
Browser
Install the module via bower
$ bower install sinon-expect
Usage
Sinon and expect matchers for Sinon are also available:
describe 'karma tests with sinon'-> it 'can spy on objects'-> foo = : -> sinonspy foo'bar' foobar 'baz' expectfoobartobecalledWith 'baz'
Additional expectation
- firstArgument
- secondArgument
- argument
- calledBefore
- calledAfter
describe 'tests sinon spy with arguments'-> it 'expect first argument'-> foo = : -> sinonspy foo'bar' foobar 'baz' expectfoobarfirstArgumenttobeequal 'baz' it 'expect second argument'-> foo = : -> sinonspy foo'bar' foobar 'baz''foo' expectfoobarsecondArgumenttobeequal 'foo' it 'expect any argument'-> foo = : -> sinonspy foo'bar' foobar 'baz''foo''bar' expectfoobarargument2tobeequal 'bar'
Conversion table
sinon.assert | expect |
---|---|
sinon.assert.calledOnce(spy) | expect(spy).to.be.calledOnce() |