UNPKG

1.99 kBMarkdownView Raw
1[![NPM version](https://badge.fury.io/js/karma-sinon-chai.png)](http://badge.fury.io/js/karma-sinon-chai) [![Dependency status](https://david-dm.org/xdissent/karma-chai.png)](https://david-dm.org/kmees/karma-sinon-chai) [![devDependency Status](https://david-dm.org/xdissent/karma-chai/dev-status.png)](https://david-dm.org/kmees/karma-sinon-chai#info=devDependencies)
2
3karma-sinon-chai
4================
5
6 * [Sinon](http://sinonjs.org/)
7 * [Chai](http://chaijs.com)
8 * [Sinon-Chai](https://github.com/domenic/sinon-chai)
9
10for [Karma](http://karma-runner.github.io)
11
12Requirements
13------------
14
15This Karma plugin requires Karma `>=0.10`
16
17Installation
18------------
19
20Install the module via npm
21
22```sh
23$ npm install --save-dev karma-sinon-chai
24```
25
26Add `sinon-chai` to the `frameworks` key in your Karma configuration:
27
28```js
29module.exports = function(config) {
30 'use strict';
31 config.set({
32 frameworks: ['mocha', 'sinon-chai'],
33
34 # chai config
35 client: {
36 chai: {
37 includeStack: true
38 }
39 }
40
41 #...
42 });
43}
44```
45
46Usage
47-----
48
49Each of the different Chai assertion suites is available in the tests:
50
51```coffee
52describe 'karma tests with chai', ->
53
54 it 'should expose the Chai assert method', ->
55 assert.ok('everything', 'everything is ok');
56
57 it 'should expose the Chai expect method', ->
58 expect('foo').to.not.equal 'bar'
59
60 it 'should expose the Chai should property', ->
61 1.should.not.equal 2
62 should.exist 123
63```
64
65Sinon and Chai matchers for Sinon are also available:
66
67```coffee
68describe 'karma tests with sinon', ->
69
70 it 'can spy on objects', ->
71 foo = bar: ->
72 sinon.spy foo, 'bar'
73
74 foo.bar 'baz'
75
76 foo.bar.should.have.been.calledWith 'baz'
77```
78
79Changelog
80----------------
81### v1.1.0
82 * Fixed broken Sinon dependency
83 * Updated depenencies
84 * Chai: `~3.0 => ~3.2.0`
85 * Sinon: `~1.15.0 => ~1.16.0`
86 * Removed `lodash` dependency
87
88### v1.0.0
89 * Updated to broken sinon version. Probably doesnt work :bomb:.