-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.ts
More file actions
25 lines (20 loc) · 720 Bytes
/
Copy pathindex.test.ts
File metadata and controls
25 lines (20 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { describe, it, expect, afterEach } from 'vitest';
import supertest from 'supertest';
import { startServer } from './index';
import http from 'http';
describe('HTTP Server', () => {
let server: http.Server;
afterEach(() => {
if (server) {
server.close();
}
});
it('should respond with "Hello from Docker!" on GET /', async () => {
server = await startServer(0); // Use port 0 to let the OS assign a free port
const port = (server.address() as any).port;
const response = await supertest(`http://localhost:${port}`)
.get('/')
.expect(200);
expect(response.text).toBe('Hello from Docker!');
});
});