Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning 'The API interface has changed' when running Karma on grunt

When running karma from a grunt task I get the following warning:

Running "karma:unit" (karma) task
Warning: The api interface has changed. Please use 
  server = new Server(config, [done])
  server.start()
instead. Use --force to continue.

Aborted due to warnings.

I have tested running karma with my configuration, both using the 'run' and 'start' karma commands and they seem to work fine.

Using grunt --force can complete the task, but it completes with warnings.

This are the versions that I'm currently using:

  • Karma 0.13.0
  • Grunt 0.4.5
  • grunt-cli 0.1.13
  • node.js 0.12.7
  • npm 2.11.3

The project was generated using yeoman (1.4.7) but I have the same problem using Karma in a separate project with just jasmine, karma and Grunt (also tested it with Gulp).

I have searched for the warning message but found nothing. I don't know if this is the expected behavior or if there is another way of completing the tasks without warnings.

like image 823
Rafael Díaz de León Avatar asked Jul 16 '15 04:07

Rafael Díaz de León


People also ask

What does it mean to set the single run attribute to true located in the Karma Conf js file?

This means that you start karma (technically the karma-server ), then go to another terminal and type karma run . Setting singleRun: true in your karma configuration will call karma run for you. Here's the doc: karma-runner.github.io/0.13/plus/requirejs.html.

What is the command used for karma configuration used for using CLI?

The configuration file can be generated using karma init : $ karma init my. conf.

What is karma config file?

The Karma configuration file can be written in JavaScript, CoffeeScript, or TypeScript and is loaded as a regular Node. js module. Unless provided as argument, the Karma CLI will look for a configuration file at. ./karma.conf.js.


2 Answers

They changed with new version here:

https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#breaking-changes

var Server = require('karma').Server;
var config = {
    configFile: path.join(__dirname, '/../karma.conf.js'),
    singleRun: singleRun,
    autoWatch: !singleRun
};

var server = new Server(config, done)
server.start()
like image 116
Kien Pham Avatar answered Sep 30 '22 13:09

Kien Pham


If you are using the grunt-karma plugin to start the Karma tests from Grunt, you need to update the grunt-karma dependency in your package.json file to 0.12.0:

"devDependencies": {
  ...
  "grunt-karma": "~0.12.0",
  ...
}

Version 0.12.0 of grunt-karma was released earlier today, and it uses the new API: https://github.com/karma-runner/grunt-karma/releases

like image 25
nwinkler Avatar answered Sep 30 '22 14:09

nwinkler