Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeEach(() => {
ipc = new AsyncEmitter();
HermioneFacade = proxyquire('lib/worker/hermione-facade', {
// TODO: think about how to make it easier
'../utils/ipc': {on: ipc.on.bind(ipc), emit: ipc.emit.bind(ipc)}
});
config = makeConfigStub();
hermione = Object.assign(new AsyncEmitter(), {
init: sandbox.spy().named('hermioneInit'),
config
});
sandbox.stub(Hermione, 'create').returns(hermione);
ipc.on('worker.init', () => {
process.nextTick(() => ipc.emit('master.init'));
});
beforeEach(() => {
ipc = new AsyncEmitter();
HermioneFacade = proxyquire('lib/worker/hermione-facade', {
// TODO: think about how to make it easier
'../utils/ipc': {on: ipc.on.bind(ipc), emit: ipc.emit.bind(ipc)}
});
config = makeConfigStub();
hermione = Object.assign(new AsyncEmitter(), {
init: sandbox.spy().named('hermioneInit'),
config
});
sandbox.stub(Hermione, 'create').returns(hermione);
ipc.on('worker.init', () => {
process.nextTick(() => ipc.emit('master.init'));
});
ipc.on('worker.syncConfig', () => {
process.nextTick(() => ipc.emit('master.syncConfig', {config}));
});
});
it('should emit STOP_BROWSER on quit', () => {
const emitter = new AsyncEmitter();
const onBrowserQuit = sinon.spy();
emitter.on(RunnerEvents.STOP_BROWSER, onBrowserQuit);
const browserManager = init_({emitter});
const browser = {foo: 'bar'};
browserManager.onQuit(browser);
assert.calledOnce(onBrowserQuit);
assert.calledWith(onBrowserQuit, browser);
});
'use strict';
const {AsyncEmitter} = require('gemini-core').events;
const {log} = require('./utils/logger');
const signalHandler = new AsyncEmitter();
signalHandler.setMaxListeners(0);
module.exports = signalHandler;
process.on('SIGHUP', notifyAndExit(1));
process.on('SIGINT', notifyAndExit(2));
process.on('SIGTERM', notifyAndExit(15));
let callCount = 0;
function notifyAndExit(signalNo) {
const exitCode = 128 + signalNo;
return function() {
if (callCount++ > 0) {
const mkRunnerStub_ = (runFn) => {
const runner = new AsyncEmitter();
runner.run = sandbox.stub(Runner.prototype, 'run').callsFake(runFn && runFn.bind(null, runner));
runner.addTestToRun = sandbox.stub(Runner.prototype, 'addTestToRun');
runner.init = sandbox.stub(Runner.prototype, 'init');
sandbox.stub(Runner, 'create').returns(runner);
return runner;
};