だから、答えはかなり簡単になった。サーバーコンストラクタへの最初の引数は、karma.conf.jsを置き換えたり拡張したりできるconfigオブジェクトです。変更されたファイル配列を送信することができます。後世のために、以下のコード:
"use strict";
var Server = require('karma').Server;
var filePath = process.cwd();
filePath += "/karma.conf.js";
console.log(filePath);
//files needs to be an array of string file matchers
function runTests(files, port) {
var config = {
configFile: filePath,
files: files,
port: port
};
var server = new Server(config, function(exitCode) {
console.log('Karma has server exited with ' + exitCode);
process.exit(exitCode)
});
server.on('run_complete', function (browser, result) {
console.log('A browser run was completed');
console.log(result);
});
server.start();
}
runTests(['test/**/*Spec.js', 'tmp/example.js'], 9876);
runTests(['test/**/*Spec.js', 'tmp/example2.js'], 9877);
runTests(['test/**/*Spec.js', 'tmp/example3.js'], 9878);
PLZまあ、彼らは任意の整形スペックやJavaScriptファイルである可能性があり – Zamboney
exampleSpec.jsとexample1-3.jsファイルを共有します。目的は、同じ仕様に対してjavascriptファイルのセットを実行し、結果を記録することです。 – AdamCooper86