Skip to content

Commit

Permalink
fix: viewport not being honoured
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Dec 17, 2022
1 parent 50822ae commit c210e16
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/core/src/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ export const resolveUserConfig: (userConfig: UserConfig) => Promise<ResolvedUser
if (!config.lighthouseOptions.formFactor) {
if (config.scanner?.device === 'mobile') {
config.lighthouseOptions.formFactor = 'mobile'
config.lighthouseOptions.screenEmulation = defu({ mobile: true }, config.lighthouseOptions.screenEmulation || {})
config.lighthouseOptions.screenEmulation = defu({
mobile: true,
width: 360,
height: 640,
deviceScaleFactor: 2,
}, config.lighthouseOptions.screenEmulation || {})
}
else if (config.scanner?.device === 'desktop') {
config.lighthouseOptions.formFactor = 'desktop'
Expand All @@ -93,7 +98,14 @@ export const resolveUserConfig: (userConfig: UserConfig) => Promise<ResolvedUser
// set default to puppeteer core
config.puppeteerClusterOptions = defu({ puppeteer }, config.puppeteerClusterOptions || {})
// point to our pre-installed chrome version
config.puppeteerOptions = defu({ executablePath: Launcher.getFirstInstallation() }, config.puppeteerOptions || {})
config.puppeteerOptions = defu({
executablePath: Launcher.getFirstInstallation(),
// set viewport
defaultViewport: {
width: config.lighthouseOptions?.screenEmulation?.width || 0,
height: config.lighthouseOptions?.screenEmulation?.height || 0,
}
}, config.puppeteerOptions || {})
}
else {
// if we can't find their local chrome, we just need to make sure they have puppeteer, this is a similar check
Expand Down

0 comments on commit c210e16

Please sign in to comment.