overleaf-cep/services/docstore/test/acceptance/js/helpers/DocstoreApp.js
Jakob Ackermann 0a7b2004d2 [misc] silence logger when running tests (#22243)
* [misc] silence logger when running tests

* [misc] re-enable logging in some tests for scripts

* [misc] make it easy to turn on verbose logging for tests

```
LOG_LEVEL=debug make test_unit
LOG_LEVEL=debug make test_acceptance
```
GitOrigin-RevId: 219bc6d1f9cbdb89ddd7d94742920913ddde4514
2025-02-10 09:06:02 +00:00

26 lines
620 B
JavaScript

const app = require('../../../../app')
const settings = require('@overleaf/settings')
module.exports = {
running: false,
initing: false,
callbacks: [],
ensureRunning(callback) {
if (this.running) {
return callback()
} else if (this.initing) {
return this.callbacks.push(callback)
}
this.initing = true
this.callbacks.push(callback)
app.listen(settings.internal.docstore.port, '127.0.0.1', error => {
if (error != null) {
throw error
}
this.running = true
for (callback of Array.from(this.callbacks)) {
callback()
}
})
},
}