-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsmoke.test.js
More file actions
31 lines (25 loc) · 755 Bytes
/
smoke.test.js
File metadata and controls
31 lines (25 loc) · 755 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
26
27
28
29
30
31
import fetch from 'node-fetch';
async function main() {
// Skip in CI (GitHub Actions sets CI=true)
if (process.env.CI) {
console.log('Skipping smoke test in CI environment');
process.exit(0);
}
const port = process.env.PORT || 3000;
const url = `http://localhost:${port}/health`;
try {
console.log(`🔎 Checking API health @ ${url} ...`);
const res = await fetch(url);
const json = await res.json();
if (!res.ok || !json.ok) {
console.error("❌ Health check didn't pass", json);
process.exit(1);
}
console.log('✅ Health check passed!', json);
process.exit(0);
} catch (error) {
console.error('❌ Smoke test failed', error?.message || error);
process.exit(1);
}
}
main();