Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function serverRunner(register) {
// register tests right away on legacy mode
if (server.isLegacy) {
return register();
}
// wrap `self.onerror`,
// remove the annoying warning caused by mocha
wrapErrorEvent();
// avoid polluting client env
require('mocha/mocha');
require('source-map-support/sw-source-map-support').install();
// wait for client request on modern mode
// DON'T use `server.on()`, this listener should be permanently added
self.addEventListener('message', (evt) => {
const {
data,
ports,
} = evt;
if (data && data.request === 'MOCHA_TASKS') {
ports[0].postMessage({
suites: runTests(register),
});
}
});
}