This package has been deprecated

Author message:

The package is no longer maintained.

@bemquery/karma-sinon-chai

2.0.3 • Public • Published

@bemquery/karma-sinon-chai

npm version Dependency status devDependency Status

Sinon + Chai + Sinon-Chai for Karma

Requirements

This Karma plugin requires Karma >=0.10

##Installation

Install the module via npm

$ npm install [--save-dev] @bemquery/karma-sinon-chai

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

module.exports = function(config) {
	'use strict';
	config.set({
		frameworks: ['mocha', 'sinon-chai'],

		# chai config
		client: {
			chai: {
				includeStack: true
			}
		}

		#...
	});
}

Usage

Each of the different Chai assertion suites is available in the tests:

describe( 'karma tests with chai', () =>
{
	it( 'should expose the Chai assert method', () => {
		assert.ok( 'everything', 'everything is ok' );
	} );

	it( 'should expose the Chai expect method', () => {
		expect( 'foo' ).to.not.equal( 'bar' );
	} );

	it( 'should expose the Chai should property', () => {
		1..should.not.equal( 2 );
		should.exist( 123 );
	} );
} );

Sinon and Chai matchers for Sinon are also available:

describe( 'karma tests with sinon', () => {
	it( 'can spy on objects', ()=> {
		var foo =  {
			bar: () => {}
		};

		sinon.spy( foo, 'bar' );

		foo.bar( 'baz' );

		foo.bar.should.have.been.calledWith( 'baz' );
	} );
} );

Package Sidebar

Install

npm i @bemquery/karma-sinon-chai

Weekly Downloads

2

Version

2.0.3

License

MIT

Last publish

Collaborators

  • comandeer