Created
January 14, 2023 16:44
-
-
Save simonespa/2d3815661fb268941d0b915e8596087f to your computer and use it in GitHub Desktop.
Lighthouse score with BBC Signin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "presets": ["@babel/preset-env"] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| })(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "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