UNPKG

@zebrunner/javascript-agent-mocha

Version:
38 lines (32 loc) 928 B
const ipc = require('node-ipc').default; const connectIPCClient = () => { ipc.config.id = `zebrunneragent_${process.pid}`; ipc.config.retry = 1500; ipc.config.maxRetries = 3; ipc.config.silent = false; ipc.connectTo('zebrunneragent', () => { ipc.of.zebrunneragent.on('connect', () => { ipc.log('Connected to zebrunneragent'); }); ipc.of.zebrunneragent.on('disconnect', () => { ipc.log('Disconnected from zebrunneragent'); }); }); }; const publishIPCEvent = (event, message) => { ipc.log(`Sending ${event} event to zebrunneragent`); try { ipc.of.zebrunneragent.emit(event, message); } catch (e) { console.error(`Error while emitting event ${event}: `, e); } }; const disconnectIPCClient = () => { ipc.log('Disconnecting from zebrunneragent'); ipc.disconnect('zebrunneragent'); }; module.exports = { connectIPCClient, publishIPCEvent, disconnectIPCClient, };