Skip to content

Commit e4e480b

Browse files
committed
how we feeling?
1 parent 3071a96 commit e4e480b

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

__tests__/smoke.test.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ async function runCheck(name, fn) {
4444
}
4545
}
4646

47-
// One Jest test that runs all smoke checks and asserts none failed
48-
test('post-deployment smoke checks', async () => {
47+
// Main smoke check function that can run standalone or in Jest
48+
async function runSmokeChecks() {
4949
const checks = []
5050

5151
// Root endpoint returns expected content
@@ -88,8 +88,32 @@ test('post-deployment smoke checks', async () => {
8888

8989
const failed = checks.filter(c => !c.ok)
9090
if (failed.length > 0) {
91-
// Fail the Jest test and print details
9291
const msg = failed.map(f => `${f.name}: ${f.error}`).join('\n')
9392
throw new Error(`Smoke tests failed:\n${msg}`)
9493
}
95-
}, 30000) // set a longer timeout for the whole test if needed
94+
95+
return { total: checks.length, passed: checks.length - failed.length, failed: failed.length }
96+
}
97+
98+
// If running standalone (node script), execute and exit with appropriate code
99+
// Check if this file is being run directly (not imported by Jest)
100+
const isRunningStandalone = import.meta.url.endsWith(process.argv[1].replace(/\\/g, '/'))
101+
if (isRunningStandalone || (typeof test === 'undefined' && process.argv[1]?.includes('smoke.test.js'))) {
102+
console.log('Running smoke tests...')
103+
runSmokeChecks()
104+
.then(result => {
105+
console.log(`✓ All ${result.total} smoke checks passed`)
106+
process.exit(0)
107+
})
108+
.catch(err => {
109+
console.error('✗ Smoke tests failed:', err.message)
110+
process.exit(1)
111+
})
112+
}
113+
114+
// If running in Jest, wrap in a test
115+
if (typeof test !== 'undefined') {
116+
test('post-deployment smoke checks', async () => {
117+
await runSmokeChecks()
118+
}, 30000) // set a longer timeout for the whole test if needed
119+
}

0 commit comments

Comments
 (0)