overleaf/services/chat/test/acceptance/js/helpers/ChatApp.js

28 lines
532 B
JavaScript
Raw Normal View History

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,
}