Closed barotrahulh123 closed 10 months ago
browser.close is not a function errror while use chrome.puppeteer i have also try by install puppeter-core
ref : https://www.npmjs.com/package/chrome-aws-lambda --------------------------------------code--------------- const chrome = require("chrome-aws-lambda"); const lighthouse = require("lighthouse");
let generate_report = async (data) => { console.log(mobileDesktopConfig); browser = await chrome.puppeteer.launch({ executablePath: await chrome.executablePath, args: chrome.args, });
const lighthousePort = new URL(browser.wsEndpoint()).port; const options = { port: lighthousePort, extends: "lighthouse:default", maxWaitForLoad: 30 * 10000, category: ["PERFORMANCE", "ACCESSIBILITY", "BEST_PRACTICES", "SEO"], ...mobileDesktopConfig, }; const outputJsonOptions = { ...options, output: "json" }; const outputHtmlOptions = { ...options, output: "html" }; console.log("sending Request now");
const runnerResultJson = await lighthouse(url, outputJsonOptions); console.log("got json", typeof runnerResultJson); const runnerResultHtml = await lighthouse(url, outputHtmlOptions); console.log("got html", typeof runnerResultHtml);
await browser.close(); }
browser.close is not a function errror while use chrome.puppeteer i have also try by install puppeter-core
ref : https://www.npmjs.com/package/chrome-aws-lambda --------------------------------------code--------------- const chrome = require("chrome-aws-lambda"); const lighthouse = require("lighthouse");
let generate_report = async (data) => { console.log(mobileDesktopConfig); browser = await chrome.puppeteer.launch({ executablePath: await chrome.executablePath, args: chrome.args, });
const lighthousePort = new URL(browser.wsEndpoint()).port; const options = { port: lighthousePort, extends: "lighthouse:default", maxWaitForLoad: 30 * 10000, category: ["PERFORMANCE", "ACCESSIBILITY", "BEST_PRACTICES", "SEO"], ...mobileDesktopConfig, }; const outputJsonOptions = { ...options, output: "json" }; const outputHtmlOptions = { ...options, output: "html" }; console.log("sending Request now");
const runnerResultJson = await lighthouse(url, outputJsonOptions); console.log("got json", typeof runnerResultJson); const runnerResultHtml = await lighthouse(url, outputHtmlOptions); console.log("got html", typeof runnerResultHtml);
await browser.close(); }