Skip to content

Commit 98d3252

Browse files
committed
add test summary
1 parent 9f421ea commit 98d3252

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

epicshop/test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,32 @@ function captureOutput() {
3232
}
3333
}
3434

35+
function printTestSummary(results) {
36+
const label = '--- Test Summary ---'
37+
console.log(`\n${label}`)
38+
for (const [appPath, result] of results) {
39+
let emoji
40+
switch (result) {
41+
case 'Passed':
42+
emoji = '✅'
43+
break
44+
case 'Failed':
45+
emoji = '❌'
46+
break
47+
case 'Error':
48+
emoji = '💥'
49+
break
50+
case 'Incomplete':
51+
emoji = '⏳'
52+
break
53+
default:
54+
emoji = '❓'
55+
}
56+
console.log(`${emoji} ${appPath}`)
57+
}
58+
console.log(`${'-'.repeat(label.length)}\n`)
59+
}
60+
3561
async function main() {
3662
const allApps = await getApps()
3763

@@ -128,6 +154,7 @@ async function main() {
128154
let hasFailures = false
129155
const runningProcesses = new Map()
130156
let isShuttingDown = false
157+
const results = new Map()
131158

132159
const shutdownHandler = () => {
133160
if (isShuttingDown) return
@@ -142,7 +169,12 @@ async function main() {
142169
} else {
143170
console.log(`ℹ️ No output captured for ${app.relativePath}`)
144171
}
172+
// Set result for incomplete tests
173+
if (!results.has(app.relativePath)) {
174+
results.set(app.relativePath, 'Incomplete')
175+
}
145176
}
177+
printTestSummary(results)
146178
// Allow some time for output to be written before exiting
147179
setTimeout(() => process.exit(1), 100)
148180
}
@@ -182,8 +214,10 @@ async function main() {
182214
console.error(`\n❌ Tests failed for ${app.relativePath}:\n\n`)
183215
output.replay()
184216
console.log('\n\n')
217+
results.set(app.relativePath, 'Failed')
185218
} else {
186219
console.log(`✅ Finished tests for ${app.relativePath}`)
220+
results.set(app.relativePath, 'Passed')
187221
}
188222
} catch (error) {
189223
runningProcesses.delete(app)
@@ -194,12 +228,16 @@ async function main() {
194228
console.error(error.message)
195229
output.replay()
196230
console.log('\n\n')
231+
results.set(app.relativePath, 'Error') // Add this line
197232
}
198233
}),
199234
)
200235

201236
await Promise.all(tasks)
202237

238+
// Print summary output
239+
printTestSummary(results)
240+
203241
if (hasFailures) {
204242
process.exit(1)
205243
}

0 commit comments

Comments
 (0)