Search code examples
karma-runnersinonchai

How to use sinon on karma?


I'm trying to use karma, chai and sinon to test spy.

  1. I did:
    npm install karma-sinon --save-dev
    
  2. I added:
    frameworks: ['mocha','chai','chai-sinon']
    
  3. I run:
    karma start
    

But I'm getting this error:

Error: No provider for "framework:chai-sinon"! (Resolving: framework:chai-sinon)

Solution

  • I had the same problem by simply adding the chai entry to the Frameworks section of my karma.conf.js script did not solve the problem. Following this Github Issue I found that you need to install the karma-cli globally, and everything else can be local and work.

     npm install --save-dev karma
     npm install -g karma-cli
     npm install --save-dev karma-phantomjs-launcher karma-chai karma-sinon