diff --git a/index.js b/index.js index 3d0ddadb..c6dc7233 100644 --- a/index.js +++ b/index.js @@ -93,8 +93,13 @@ app.use("/api/draw", drawRoutes); // Error handler (doit être après les routes) app.use(errorHandler); -// Lancement serveur -const PORT = config.server.port; -app.listen(PORT, "0.0.0.0", () => { - console.log(`🚀 Backend lancé sur 0.0.0.0:${PORT} ✅`); -}); \ No newline at end of file +// Export app for testing +export default app; + +// Lancement serveur (seulement si pas importé par les tests) +if (process.env.NODE_ENV !== 'test') { + const PORT = config.server.port; + app.listen(PORT, "0.0.0.0", () => { + console.log(`🚀 Backend lancé sur 0.0.0.0:${PORT} ✅`); + }); +} \ No newline at end of file diff --git a/test/app.test.js b/test/app.test.js index 2fd6a0ba..fd274a2b 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -1,5 +1,5 @@ -const request = require('supertest'); -const app = require('../index'); // ton serveur express +import request from 'supertest'; +import app from '../index.js'; describe('Test API health', () => { it('GET /health doit répondre 200', async () => {