-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.e2e.test.js
More file actions
32 lines (26 loc) · 1.04 KB
/
app.e2e.test.js
File metadata and controls
32 lines (26 loc) · 1.04 KB
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
26
27
28
29
30
31
32
import { describe, it, expect } from 'vitest';
import request from 'supertest';
// Use environment variable or default to localhost for testing
const baseURL = process.env.TEST_BASE_URL || 'http://localhost:3000';
describe('API Tests', () => {
it('should return Hello World from GET /', async () => {
const res = await request(baseURL).get('/');
expect(res.statusCode).toBe(200);
expect(res.text).toBe('Hello World!');
});
it('should respond within reasonable time', async () => {
const start = Date.now();
const res = await request(baseURL).get('/');
const duration = Date.now() - start;
expect(res.statusCode).toBe(200);
expect(duration).toBeLessThan(1000); // Should respond within 1 second
});
it('should handle multiple concurrent requests', async () => {
const requests = Array(5).fill().map(() => request(baseURL).get('/'));
const responses = await Promise.all(requests);
responses.forEach(res => {
expect(res.statusCode).toBe(200);
expect(res.text).toBe('Hello World!');
});
});
});