overleaf/services/chat/test/acceptance/js/helpers/ChatApp.js
Tim Alby 795ed56034 asyncify tests
GitOrigin-RevId: 62f875bb121a599fab830a3244959596796cd6e1
2022-01-14 09:03:08 +00:00

27 lines
532 B
JavaScript

const { waitForDb } = require('../../../../app/js/mongodb')
const app = require('../../../../app')
let serverPromise = null
function startServer(resolve, reject) {
waitForDb()
.then(() => {
app.listen(3010, 'localhost', error => {
if (error) {
return reject(error)
}
resolve()
})
})
.catch(reject)
}
async function ensureRunning() {
if (!serverPromise) {
serverPromise = new Promise(startServer)
}
return serverPromise
}
module.exports = {
ensureRunning,
}