UNPKG

1.25 kBMarkdownView Raw
1karma-sinon-chai
2================
3
4 * [Sinon](http://sinonjs.org/)
5 * [Chai](http://chaijs.com)
6 * [Sinon-Chai](https://github.com/domenic/sinon-chai)
7
8for [Karma](http://karma-runner.github.io)
9
10Requirements
11------------
12
13This Karma plugin requires Karma `~0.10.0`
14
15Installation
16------------
17
18Install the module via npm
19
20```sh
21$ npm install --save-dev karma-sinon-chai
22```
23
24Add `sinon-chai` to the `frameworks` key in your Karma configuration:
25
26```js
27module.exports = function(config) {
28 'use strict';
29 config.set({
30 frameworks: ['mocha', 'sinon-chai'],
31 #...
32 });
33}
34```
35
36Usage
37-----
38
39Each of the different Chai assertion suites is available in the tests:
40
41```coffee
42describe 'karma tests with chai', ->
43
44 it 'should expose the Chai assert method', ->
45 assert.ok('everything', 'everything is ok');
46
47 it 'should expose the Chai expect method', ->
48 expect('foo').to.not.equal 'bar'
49
50 it 'should expose the Chai should property', ->
51 1.should.not.equal 2
52 should.exist 123
53```
54
55Sinon and Chai matchers for Sinon are also available:
56
57```coffee
58describe 'karma tests with sinon', ->
59
60 it 'can spy on objects', ->
61 foo = bar: ->
62 sinon.spy foo, 'bar'
63
64 foo.bar 'baz'
65
66 foo.bar.should.have.been.calledWith 'baz'
67```