generator-karma editorconfig travis-ci npm

Yeoman generator for Karma

Karma generator Build Status

See the Karma documentation for more info.

Why Karma?

Karma runs the tests in the browser, but reports them in the CLI. This greatly improves your workflow by giving you constant, accurate feedback on the status of your tests.


Install it globally npm install -g generator-karma.

Running yo karma will generate a config file for your project: karma.conf.js. It will then install the npm dependencies.

By default, running yo karma will generate a pretty boring (and almost useless) config file. The real power is using the options to specify almost every part of the config file.


There are a lot of options going on here. None of them are required and most are probably only useful when used with other generators calling this one.

Options are specified after yo karma. Example:

yo karma --skip-install --frameworks=jasmine --app-files='app/**/*.js,public/**/*.js'

The full list:

  • --frameworks Type: String, Default: ‘jasmine’

Specifies which testing frameworks to use (CSV list). Example --frameworks=mocha,chai,requirejs,sinon

  • --browsers Type: String, Default: ‘PhantomJS’

What browsers to test in (CSV list).

  • --app-files Type: String, Default: “

List of application files (CSV list). There are purely the files you edit that make up your test.

  • --test-files Type: String, Default: “

List of test files (CSV list), including spec and mock files.

  • --files-comments Type: String, Default: “

List of comments to add to files properties. It can be used to support bower dependencies wiring using wiredep.

  • --exclude-files Type: String, Default: “

List of files to exclude (CSV list). Files you don’t want tested.

  • --plugins Type: String, Default: “

Specify Karma plugins (npm modules). Use the full name like karma-junit-reporter.

  • --bower-components Type: String, Default: “

Optional components to use for testing (CSV list of components).

  • --bower-components-path Type: String, Default: ‘bower_components’

Directory where Bower components are installed, if not in the default location.

  • --base-path Type: String, Default: “

Will be used to resolve files and exclude in the karma.conf.js file.

  • --web-port Type: Number, Default: 8080

Web server port to run Karma from.

  • --template-path Type: String, Default: ‘../templates’

If you would like to specify a different template to use, give the path to that folder.

  • --config-file Type: String, Default: “

The config file name to write to. Useful if you want a different name like karma-e2e.conf.js.

  • --config-path Type: String, Default: ‘./test’

Path where the config files should be written to. This is where the karma.conf.js file will be placed.

Composing With This Generator

This generator is now able to work with other generators. Any option specified above can be passed in. All of the csv type arguments can also accept arrays.

To use this, first include it as a devDependencies in the calling generator.

Next, include the code to actually use it:

this.composeWith('karma:app', {
  options: {
    frameworks: ['mocha', 'chai', 'sinon']
}, {
  local: require.resolve('generator-karma/generators/app/index.js')

Migrating from version 1: The CoffeeScript and Gruntfile options have been remove. This is to make this generator more streamlined. Those should be built on top of this generator if people want a generator with that functionality.


Karma can be configured by editing karma.conf.js. See the documentation page on the config file for an exhaustive list of options.


See the contributing docs


BSD license

Related Repositories



Yeoman generator for Karma ...



A Yeoman generator for creating universal JavaScript modules that work everywhere using ES2015, Babel, Webpack, Mocha, Chai, Karma, Sinon, Isparta, ESLint ...



A Yeoman generator for creating a ready-to-develop configuration of the ng2-mean-webpack MEAN stack flavor—Angular 2 (Router, Http, Forms, Services, Tests, E2E, Coverage), Express, MongoDB, Mongoose, Node, PassportJS,, Karma, Protractor, Jasmine ...



Yeoman generator for front end apps using gulp, Karma, Mocha & other goodies ...



Yeoman Generator for angular that uses Webpack as a module bundler, SASS as CSS preprocessor, UI router as default angular route, Karma with Jasmine for testing and Auto-generated Docs. ...

Top Contributors

eddiemonge sindresorhus btford passy SBoudrias kevva addyosmani mklabs seriema sleeper guzart DaftMonk zenorocha artoale alfonso-presa arthurvr Globegitter jonathanhaynes safjanowski EloB stephenplusplus Toilal tomlane tomwayson vojtajina X1011 hemanth


-   v2.0.0 zip tar
-   v1.0.1 zip tar
-   v1.0.0 zip tar
-   v0.9.0 zip tar
-   v0.8.3 zip tar
-   v0.8.2 zip tar
-   v0.8.1 zip tar
-   v0.8.0 zip tar
-   v0.7.0 zip tar
-   v0.6.0 zip tar
-   v0.5.0 zip tar
-   v0.4.1 zip tar
-   v0.4.0 zip tar
-   v0.3.1 zip tar
-   v0.3.0 zip tar
-   v0.2.0 zip tar
-   v0.1.1 zip tar
-   v0.1.0 zip tar