1. karma-sinon-chai
Sinon and Chai for Karma
karma-sinon-chai
Package: karma-sinon-chai
Created by: kmees
Last modified: Sun, 19 Jun 2022 08:05:12 GMT
Version: 2.0.2
License: MIT
Downloads: 135,925
Repository: https://github.com/kmees/karma-sinon-chai

Install

npm install karma-sinon-chai
yarn add karma-sinon-chai

NPM version Dependency status devDependency Status

karma-sinon-chai

for Karma

Requirements

This Karma plugin requires Karma >=0.10

Installation

Install the module via npm

 $ npm install --save-dev 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', ->
    foo = bar: ->
    sinon.spy foo, 'bar'

    foo.bar 'baz'

    foo.bar.should.have.been.calledWith 'baz'

Changelog

v2.0.0

  • Removed lolex dependency. Please use Sinon's fake timers instead, which use lolex under the hood.

v1.1.0

  • Fixed broken Sinon dependency
  • Updated depenencies
    • Chai: ~3.0 => ~3.2.0
    • Sinon: ~1.15.0 => ~1.16.0
  • Removed lodash dependency

v1.0.0

  • Updated to broken sinon version. Probably doesnt work :bomb:.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin