debug: add coverage collection logging to diagnose 0/0 coverage

This commit is contained in:
bymyself
2026-04-07 01:12:13 -07:00
parent 8b3feb2abb
commit 9c557f6a79

View File

@@ -420,14 +420,42 @@ export const comfyPageFixture = base.extend<{
await use(page)
const entries = await page.coverage.stopJSCoverage()
// Debug: log coverage entry stats
const httpEntries = entries.filter((e) => e.url.startsWith('http'))
const withSource = entries.filter(
(e) => typeof e.source === 'string'
).length
console.log(
`[coverage] ${testInfo.title}: ${entries.length} entries, ${httpEntries.length} HTTP, ${withSource} with source`
)
if (httpEntries.length > 0) {
console.log(
`[coverage] Sample URLs: ${httpEntries
.slice(0, 3)
.map((e) => e.url)
.join(', ')}`
)
}
let fetchedCount = 0
for (const entry of entries) {
if (typeof entry.source !== 'string' && entry.url.startsWith('http')) {
try {
const resp = await fetch(entry.url)
if (resp.ok) (entry as Record<string, unknown>).source = await resp.text()
} catch {}
if (resp.ok) {
;(entry as Record<string, unknown>).source = await resp.text()
fetchedCount++
} else {
console.log(
`[coverage] fetch failed ${entry.url}: ${resp.status}`
)
}
} catch (err) {
console.log(`[coverage] fetch error ${entry.url}: ${err}`)
}
}
}
console.log(`[coverage] Fetched sources for ${fetchedCount} scripts`)
const resultFile = testInfo.outputPath('v8-coverage.json')
await fs.writeFile(resultFile, JSON.stringify({ result: entries }))