forked from ryanmwangi/CalMerger
test(calendar): use correct subdirectory to run server
This commit is contained in:
parent
5b40bf5d75
commit
c8f3771717
|
@ -2,13 +2,13 @@ import express from 'express';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import routes from './routes.js';
|
import routes from './routes.js';
|
||||||
|
|
||||||
|
console.log(`Starting server in ${process.cwd()}`);
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
|
|
||||||
// Serve static files from the 'public' directory
|
// Serve static files from the 'public' directory
|
||||||
app.use(express.static(path.join(process.cwd(), 'public')));
|
app.use(express.static(path.join(process.cwd(), 'public')));
|
||||||
app.use('/', routes);
|
app.use('/', routes);
|
||||||
|
|
||||||
|
export default app;
|
||||||
export default app;
|
|
|
@ -1,8 +1,6 @@
|
||||||
import request from 'supertest';
|
import request from 'supertest';
|
||||||
import express from 'express';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { jest } from '@jest/globals';
|
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
// ESM equivalent of __dirname
|
// ESM equivalent of __dirname
|
||||||
|
@ -15,15 +13,14 @@ const EXPECTED_OUTPUTS_DIR = path.join(__dirname, 'expected_outputs');
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
process.chdir(__dirname)
|
process.chdir(__dirname)
|
||||||
console.log(process.cwd());
|
const app = await import('../src/server');
|
||||||
import app from '../src/server.js';
|
|
||||||
|
|
||||||
const normalizeLineEndings = (str) => str.replace(/\r\n/g, '\r\n').trimEnd(); // Normalize to CRLF
|
const normalizeLineEndings = (str) => str.replace(/\r\n/g, '\r\n').trimEnd(); // Normalize to CRLF
|
||||||
|
|
||||||
describe('Calendar Merging API', () => {
|
describe('Calendar Merging API', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// Start the server
|
// Start the server
|
||||||
server = app.listen(0);
|
server = app.default.listen(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
|
Loading…
Reference in New Issue