Skip to content

Instantly share code, notes, and snippets.

Last active January 20, 2023 21:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Generate Lighthouse script from Recorder panel
* 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 ``. View that.
* It's one of these:
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`);
Copy link

And sneak peek.. but soon, there will be a new option in the Recorder panel which will replace this gist and directly provide you the yourrecording.pptr.js script:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment