Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const KarmaServer = require('karma').Server;
const karmaStopper = require('karma').stopper;
const path = require('path');
const defaultTimeout = 100000;
// I have a similar issue, but this is alread closed:
// Karma doesn't exit properly when using public api with the finish callback #1035
// https://github.com/karma-runner/karma/issues/1035
var OperationKarma = (function() {
function OperationKarma(config, op) {
this.config = config;
this.op = op;
this.timeout = this.op.timeout || defaultTimeout;
public stopServer(): void {
karma.stopper.stop();
}
}
return new Promise(resolve => {
const stopper = require("karma").stopper;
stopper.stop({ port: 9876 }, (exitCode: any) => {
resolve();
});
});
}
return new Promise(resolve => {
if (this.karmaEventListener.isServerLoaded) {
const stopper = require("karma").stopper;
stopper.stop({ port: 9876 }, (exitCode: number) => {
this.logger.info(`Karma exited succesfully`);
resolve();
this.karmaEventListener.stopListeningToKarma();
});
}
});
}
server.on('listening', (port) => {
let browsers = server.get('config').browsers;
if (!browsers || browsers.length === 0) {
karma.stopper.stop({ port });
}
});
}
return new Promise((resolve) => {
karma.stopper.stop(this.server, resolve);
});
}