sahat / karma-mocha

A Karma plugin. Adapter for Mocha testing framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

karma-mocha Build Status

Adapter for the Mocha testing framework.

Installation

The easiest way is to keep karma-mocha as a devDependency in your package.json.

{
  "devDependencies": {
    "karma-mocha": "~0.1"
  }
}

You can simple do it by:

npm install karma-mocha --save-dev

How install karma you can red here.

Configuration

Following code shows the default configuration...

// karma.conf.js
module.exports = function(config) {
  config.set({
    frameworks: ['mocha'],

    files: [
      '*.js'
    ]
  });
};

If you want to pass configuration options directly to mocha you can do this in the following way

// karma.conf.js
module.exports = function(config) {
  config.set({
    frameworks: ['mocha'],

    files: [
      '*.js'
    ],

    client: {
      mocha: {
        ui: 'tdd'
      }
    }
  });
};

If you want run only some tests matching a given pattern you can do this in the following way

karma start &
karma run -- --grep=<pattern>

or

module.exports = function(config) {
  config.set({
    ...
    client: {
      args: ['--grep', '<pattern>'],
      ...
    }
  });
};

--grep argument pass directly to mocha


For more information on Karma see the homepage.

About

A Karma plugin. Adapter for Mocha testing framework.

License:MIT License