|
1 | | -// import assert from 'node:assert/strict'; |
2 | | -// assert.equal(1 + 1, 2, 'Math still works'); |
3 | | -// import '../server/server.js'; |
4 | | -// console.log('✅ smoke test passed'); |
5 | | -// import 'dotenv/config'; |
6 | | -// import { healthCheck } from '../server/db.js'; |
| 1 | +import fetch from 'node-fetch'; |
7 | 2 |
|
8 | | -// async function main() { |
9 | | -// try { |
10 | | -// console.log('Running a smoke test'); |
| 3 | +const port = process.env.PORT || 4000; |
| 4 | +const url = `http://localhost:${port}/health`; |
11 | 5 |
|
12 | | -// const ok = await healthCheck(); |
13 | | -// if (!ok) { |
14 | | -// console.error("❌ Health check didn't pass"); |
15 | | -// process.exit(1); |
16 | | -// } |
| 6 | +async function main() { |
| 7 | + try { |
| 8 | + console.log(`🔎 Checking API health @ ${url} ...`); |
| 9 | + const res = await fetch(url); |
| 10 | + const json = await res.json(); |
17 | 11 |
|
18 | | -// console.log('✅ Health check passed!'); |
19 | | -// process.exit(0); |
20 | | -// } catch (error) { |
21 | | -// console.error('Smoke test failed'); |
22 | | -// process.exit(1); |
23 | | -// } |
24 | | -// } |
| 12 | + // const ok = await healthCheck(); |
| 13 | + if (!res.ok || !json.ok) { |
| 14 | + console.error('❌ Health check didn"t pass', json); |
| 15 | + process.exit(1); |
| 16 | + } |
25 | 17 |
|
26 | | -// main(); |
27 | | -console.log('✅ CI smoke test stub: nothing to check yet.'); |
28 | | -process.exit(0); |
| 18 | + console.log('✅ Health check passed!', json); |
| 19 | + process.exit(0); |
| 20 | + } catch (error) { |
| 21 | + console.error('❌ Smoke test failed'); |
| 22 | + process.exit(1); |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +main(); |
0 commit comments