Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const waitOnPromise = options => new Promise(resolve => waitOn(options, resolve));
const wait = time => new Promise(resolve => setTimeout(resolve, time));
const { launchTimeout, protocol, host, port, waitOnScheme } = config
let url = ''
if (protocol === 'tcp' || protocol === 'socket') {
url = `${protocol}:${host}:${port}`
} else {
url = `${protocol}://${host}:${port}`
}
const opts = {
resources: [url],
timeout: launchTimeout,
...waitOnScheme,
}
try {
await waitOn(opts)
} catch (err) {
throw new JestDevServerError(
`Server has taken more than ${launchTimeout}ms to start.`,
ERROR_TIMEOUT,
)
}
}
}
new Promise((resolve, reject) =>
waitOn(options, err => {
if (err) return reject(err);
resolve();
}),
);