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:
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.
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.
The configuration file can be generated using karma init : $ karma init my. conf.
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.
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()
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With