From c8f37717171d207c7cdf6f0bba07b1369d88ed36 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Mon, 25 Nov 2024 12:55:34 +0100 Subject: [PATCH] test(calendar): use correct subdirectory to run server --- src/server.js | 6 +++--- test/calendar.test.js | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/server.js b/src/server.js index 851fcc2..b86cca0 100644 --- a/src/server.js +++ b/src/server.js @@ -2,13 +2,13 @@ import express from 'express'; import path from 'path'; import routes from './routes.js'; +console.log(`Starting server in ${process.cwd()}`); + const app = express(); app.use(express.json()); - // Serve static files from the 'public' directory app.use(express.static(path.join(process.cwd(), 'public'))); app.use('/', routes); - -export default app; +export default app; \ No newline at end of file diff --git a/test/calendar.test.js b/test/calendar.test.js index 79a42a5..108c539 100644 --- a/test/calendar.test.js +++ b/test/calendar.test.js @@ -1,8 +1,6 @@ import request from 'supertest'; -import express from 'express'; import fs from 'fs'; import path from 'path'; -import { jest } from '@jest/globals'; import { fileURLToPath } from 'url'; // ESM equivalent of __dirname @@ -15,15 +13,14 @@ const EXPECTED_OUTPUTS_DIR = path.join(__dirname, 'expected_outputs'); let server; process.chdir(__dirname) -console.log(process.cwd()); -import app from '../src/server.js'; +const app = await import('../src/server'); const normalizeLineEndings = (str) => str.replace(/\r\n/g, '\r\n').trimEnd(); // Normalize to CRLF describe('Calendar Merging API', () => { beforeAll(async () => { // Start the server - server = app.listen(0); + server = app.default.listen(0); }); afterAll(async () => {