HealthCheck.test.ts 910 B

1234567891011121314151617181920212223242526272829303132
  1. import { beforeAll, describe, it, expect } from 'vitest'
  2. import { fetchStringWithResponse } from '@overleaf/fetch-utils'
  3. import app from '../../../app.ts'
  4. import logger from '@overleaf/logger'
  5. import './MongoHelper.ts'
  6. let runAppPromise: Promise<void> | null = null
  7. async function ensureRunning(hostname: string, port: number) {
  8. if (!runAppPromise) {
  9. runAppPromise = new Promise(resolve => {
  10. app.listen(port, hostname, () => {
  11. logger.info({ port, hostname }, 'notifications running in dev mode')
  12. resolve()
  13. })
  14. })
  15. }
  16. await runAppPromise
  17. }
  18. describe('HealthCheck endpoint', () => {
  19. beforeAll(async () => {
  20. await ensureRunning('127.0.0.1', 3042)
  21. })
  22. it('should return 200 for GET /health_check', async () => {
  23. const { response } = await fetchStringWithResponse(
  24. 'http://localhost:3042/health_check'
  25. )
  26. expect(response.status).toBe(200)
  27. })
  28. })