Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop/mobile mode Playwright-lighthouse Audit reports #32

Open
perftest22 opened this issue Jul 29, 2022 · 2 comments
Open

Desktop/mobile mode Playwright-lighthouse Audit reports #32

perftest22 opened this issue Jul 29, 2022 · 2 comments

Comments

@perftest22
Copy link

Hi, I am new to this tool. I was trying to get the performance audit for both desktop and mobile in the same script. I tried the formFactor:'desktop' , but by default it is going to the mobile mode only. The only way I could find the solution is to change the defaultsettings in the constants.js config file(\lighthouse\lighthouse-core\config\constants.js) and also I needed to create two separate projects, one for desktop and one for mobile mode. Is there a way I can get both desktop and mobile audit reports in the same script?. Please advise! Thank you.

const defaultSettings = {
output: 'json',
maxWaitForFcp: 30 * 1000,
maxWaitForLoad: 45 * 1000,

formFactor: 'mobile',
throttling: throttling.mobileSlow4G,
throttlingMethod: 'simulate',
screenEmulation: screenEmulationMetrics.mobile,
emulatedUserAgent: userAgents.mobile,

@perftest22 perftest22 changed the title Desktop/mobile Desktop/mobile mode Playwright-lighthouse Audit reports Jul 29, 2022
@ryanrosello-og
Copy link

hey @perftest22

try creating your own helper function to set the default settings. For example:

import lighthouseDesktopConfig from 'lighthouse/lighthouse-core/config/lr-desktop-config';
import lighthouseMobileConfig from 'lighthouse/lighthouse-core/config/lr-mobile-config';

function lightHouseConfig(options: {
  name: string;
  page: Page;
  port: number;
  formFactor: 'desktop' | 'mobile';
  outputDirectory: string;
}): playwrightLighthouseConfig {
  const {formFactor, page, port, name, outputDirectory} = options;
  return {
    page,
    port,
    config: formFactor === 'desktop' ? lighthouseDesktopConfig : lighthouseMobileConfig,
    reports: {
      formats: {
        html: true,
        json: true,
      },
      name: FileHelpers.sanitizeFileName(name),
      directory: outputDirectory,
    },
  };
}

export {lightHouseConfig};

Note the formFactor setting which will load the required config based on the value that you set.

@perftest22
Copy link
Author

Thank you for helping. I will try it out and let you know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants