Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chai is not defined in Karma-mocha

I am running my test cases succesfully using mocha-phantomjs configurations. Now I am running these test using Karma launcher. But I get the issue Chai is not defined.

Here is my configuration file.

 module.exports = function(config) {
  config.set({
    client: {
        mocha: {
            ui: 'tdd'
        }
    },
    basePath: '',
    frameworks: ['mocha'],
    files: [
      'web/js/*.js',
      'test/lib/*.js',
      'node_modules/chai/chai.js'  //added this on suggestion of the answer in stackoverflow
    ],
    exclude: [
    ],
    preprocessors: {
    },
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Firefox'],
    singleRun: false,
  });
};

enter image description here

I have researched on it and found this links,

like image 268
ankitr Avatar asked Jul 25 '14 10:07

ankitr


1 Answers

I installed the karma-chai plugin for chai https://github.com/eclifford/karma-chai-jquery/issues/3

Change frameworks to this.

frameworks: ['mocha', 'chai']

and add these dependencies.

npm install karma-chai --save-dev

Now I have solved my problem. Hope this will help you also.

like image 140
ankitr Avatar answered Sep 30 '22 06:09

ankitr