* @param url the URL to run Lighthouse against * @param flags Lighthouse flags * @param config Lighthouse JSON config * @returns the result of the Lighthouse run
(url, flags, config)
| 136 | * @returns the result of the Lighthouse run |
| 137 | */ |
| 138 | async function launchChromeAndRunLighthouse(url, flags, config) { |
| 139 | const browser = await puppeteer.launch({ |
| 140 | // Allow for a custom chromium to be provided (e.g. for M1 native support) |
| 141 | executablePath: process.env.CHROMIUM_BIN, |
| 142 | args: ['--no-sandbox'], |
| 143 | headless: 'new', |
| 144 | }); |
| 145 | |
| 146 | const page = await browser.newPage(); |
| 147 | |
| 148 | try { |
| 149 | return await lighthouse(url, flags, config, page); |
| 150 | } finally { |
| 151 | await page.close(); |
| 152 | await browser.close(); |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * @param {string} err the error message |