You can chain multiple karma runners using karma programmatically.
Karma offers an API to make it work programmatically (which is not that clear IMHO - some examples can improve it).
First of all you need an array of configurations then you need to call karma programmatically and chain the calls.
Create an array of configurations
function getConfiguration(filename){
return {
// you can enrich the template file here if you want
// e.g. add some preprocessor based on the configuration, etc..
//
// if not set in the config template
// make Karma server launch the runner as well
singleRun: true,
// point to the template
configFile : __dirname + filename
};
}
function createConfigurations(){
return [getConfiguration('conf1.js'), getConfiguration('conf2.js'), etc...];
}
Start Karma programmatically
function startKarma(conf, next){
karma.server.start(conf, function(exitCode){
// exit code === 0 is OK
if (!exitCode) {
console.log('\tTests ran successfully.\n');
// rerun with a different configuration
next();
} else {
// just exit with the error code
next(exitCode);
}
});
Chain the karma runners
// Use the async library to make things cleaner
var async = require('async');
var karma = require('karma');
var confs = createConfigurations();
async.eachSeries(confs, startKarma, function(err){
if(err){
console.log('Something went wrong in a runner');
else {
console.log('Yay! All the runners have finished ok');
}
});