import { describe, it, expect } from 'vitest'; // fetch is global in Node 18+ describe('Integration Tests', () => { const FRONTEND_URL = 'http://localhost:80'; const BACKEND_URL = 'http://localhost:3001'; it('Frontend is reachable', async () => { try { const res = await fetch(FRONTEND_URL); expect(res.status).toBe(200); const text = await res.text(); expect(text).toContain(''); } catch (e) { // If fetch fails (connection refused), test fails throw new Error(`Frontend not reachable at ${FRONTEND_URL}: ${e.message}`); } }); it('Backend health check / API is reachable', async () => { // We don't have a specific health endpoint, but we can try to hit an auth endpoint // that requires valid input, expecting a 400 or 401 instead of connection refused. try { const res = await fetch(`${BACKEND_URL}/api/auth/login`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}) }); // Expecting 400 because we sent empty body, meaning server is up and parsing JSON expect(res.status).toBe(400); } catch (e) { throw new Error(`Backend not reachable at ${BACKEND_URL}: ${e.message}`); } }); });