/** * To use: * Export a Recording panel recording as JSON. Run this: * node generate-pptr-lh-script-from-json.mjs yourjson.json * It'll save a `yourjson.json.pptr.js` * That script is dependent on: * lighthouse@9.5.0-dev.20221024 * puppeteer@19.4.1 * Run that script. It'll save a `flow.report.html`. View that. * It's one of these: https://web.dev/lighthouse-user-flows/ */ import fs from 'node:fs'; import {stringify, LighthouseStringifyExtension} from '@puppeteer/replay'; const filename = process.argv[2]; const flow = JSON.parse(fs.readFileSync(filename, 'utf-8')); const scriptContents = await stringify(flow, { extension: new LighthouseStringifyExtension(), }); fs.writeFileSync(`${filename}.pptr.cjs`, scriptContents, 'utf-8'); console.log('Puppeteer+Lighthouse script written to: ', `${filename}.pptr.cjs`);