-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-500-error.js
More file actions
33 lines (28 loc) · 1.1 KB
/
test-500-error.js
File metadata and controls
33 lines (28 loc) · 1.1 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
33
// test-500-error.js
// Script to test 500 Internal Server Error
const axios = require('axios');
const BASE_URL = 'http://localhost:5000/api';
async function test500Error() {
console.log('🔧 Testing 500 Internal Server Error...\n');
// Test 1: Using the test endpoint
console.log('1. Testing GET /api/bookings/test/500-error');
try {
const response = await axios.get(`${BASE_URL}/bookings/test/500-error`);
console.log('❌ Should have failed with 500 error');
} catch (error) {
if (error.response?.status === 500) {
console.log('✅ Correctly returned 500 error');
console.log('Status:', error.response.status);
console.log('Message:', error.response.data.message);
} else {
console.log('❌ Unexpected error:', error.response?.status);
}
}
console.log('\n' + '='.repeat(50));
console.log('📝 To test real 500 errors:');
console.log('1. Stop your MongoDB Atlas connection');
console.log('2. Try to create a booking');
console.log('3. You should get a 500 error');
console.log('4. Restart MongoDB connection to continue testing');
}
test500Error();