Skip to content

Instantly share code, notes, and snippets.

@simonespa
Created January 14, 2023 16:44
Show Gist options
  • Select an option

  • Save simonespa/2d3815661fb268941d0b915e8596087f to your computer and use it in GitHub Desktop.

Select an option

Save simonespa/2d3815661fb268941d0b915e8596087f to your computer and use it in GitHub Desktop.
Lighthouse score with BBC Signin
{
"presets": ["@babel/preset-env"]
}
import { getSignedInPage } from '@bbc/signin';
import lighthouse from 'lighthouse';
import { URL } from 'url';
import { writeFileSync } from 'fs';
const url = 'https://www.bbc.co.uk/sounds';
(async () => {
try {
const puppeteer = await getSignedInPage({
username: process.env.BBC_USERNAME,
password: process.env.BBC_PASSWORD
});
const browser = puppeteer[1];
const { lhr } = await lighthouse(url, {
port: (new URL(browser.wsEndpoint())).port,
output: 'html',
logLevel: 'info'
});
writeFileSync('./lhr.html', JSON.stringify(lhr));
await browser.close();
} catch (e) {
console.log(e);
}
})();
{
"name": "lighthouse-score",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "BABEL_ENV=test babel-node index.js"
},
"keywords": ["lighthouse", "bbc", "signin"],
"author": "Simone Spaccarotella",
"dependencies": {
"@bbc/signin": "^1.2.3",
"lighthouse": "^4.0.0-alpha.2-3.2.1"
},
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/node": "^7.0.0",
"@babel/preset-env": "^7.1.6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment