File size: 1,217 Bytes
af1bee9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #!/usr/bin/env node
// Checks that every attachment path (trace, screenshot, video, ...) referenced in a Playwright results.json exists.
// Usage: node scripts/verify-artifacts.js [results.json] (default results/results.json). Exit 1 if any are missing.
const fs = require('fs'); const path = require('path');
const file = path.resolve(process.argv[2] || path.join(__dirname, '../results/results.json'));
const r = JSON.parse(fs.readFileSync(file, 'utf8'));
const seen = []; const missing = []; const kinds = {};
const walk = (s) => { (s.specs || []).forEach((sp) => sp.tests.forEach((t) => t.results.forEach((res) => (res.attachments || []).forEach((a) => {
if (!a.path) return; seen.push(a.path); kinds[a.name] = (kinds[a.name] || 0) + 1; if (!fs.existsSync(a.path)) missing.push(`${sp.title} :: ${a.name} :: ${a.path}`);
})))); (s.suites || []).forEach(walk); };
(r.suites || []).forEach(walk);
console.log(`verify-artifacts ${path.relative(process.cwd(), file)}: ${seen.length} attachment paths (${Object.entries(kinds).map(([k, v]) => `${k}=${v}`).join(', ')}), missing ${missing.length}`);
missing.slice(0, 20).forEach((m) => console.log(' MISSING', m));
process.exit(missing.length ? 1 : 0);
|