Tea not defined in Karma Mokka

I am successfully running my test cases using mocha-phantomjs configurations. Now I run this test using the Karma launcher. But I get a question 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 researched it and found these links ,

+4
source share
2 answers

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

Change the scope for this.

frameworks: ['mocha', 'chai']

and add these dependencies.

npm install karma-chai --save-dev

Now I have solved my problem. Hope this helps you too.

+5
source

karma-chai chai , , , , , , chai bower bower_components/chai/chai.js , . , :

files: [
  'bower_components/chai/chai.js',
  '*.test.js'
],

node_modules/chai/chai.js, , , - StackOverflow. , , .

karma.conf.js https://npmjs.org/browse/keyword/karma-adapter , , karma-chai , -, , RequireJS.

+1

All Articles