pwmetrics
pwmetrics copied to clipboard
Unable to pass params to Lighthouse when using an external configuration
Config / CLI options
Steps to reproduce.
Using either combo --
pwmetrics --config --disable-device-emulation
pwmetrics --disable-device-emulation --config
pwmetrics doesn't pass the parameters to Lighthouse. Same behavior occurs using either JSON or JavaScript configuration files. Without a '--config=' argument, parameters are passed successfully.
Environment
-
pwmetrics
version: 3.1.4 - Lighthouse version: 2.8.0
Any update on this issue.
Commands aren't documented well, but use the following flags in the config file --
disableDeviceEmulation: true
disableNetworkThrottling: true
disableCpuThrottling: true
Trying to decipher how to set cookies now.
@jbelew Had any luck in setting cookies?
disableStorageReset:True might help. @jbelew Is that correct?
@jbelew @santoshjoseph99 were you able to set your cookies for auth pages and get that to work??
Set up my config something like this but it routes to login:
testURLs.forEach((pageURL) => {
const pathName = new URL(pageURL).pathname;
const metric = new PWMetrics(pageURL, {
flags: {
// port: 59999,
logLevel: 'debug',
runs: 2,
expectations: false,
disableCpuThrottling: true,
disableStorageReset: true,
// chromeFlags: '--headless',
json: true,
outputPath: `perf/metrics${pathName}.json`,
emulatedFormFactor: 'desktop',
extraHeaders: {
Cookie: `JSESSIONID=${process.env.JSESSIONID};CSRFToken=${process.env.CSRFToken};SessionId=${process.env.SessionId}`
}
}
});
metric.start()
.then(result => console.log('Perf Run:', result)) // eslint-disable-line no-console
.catch(e => console.error(e));// eslint-disable-line no-console
I had a similar issue with trying to login and use an http only cookie. I had a puppeteer script to login first. The trick is that you need to set the flags.disabledStorageReset: true
and you need to set the flags.port to the same port that you used for puppeteer. So if you are trying to reuse your session, try doing something like that.
@chrisrink then I don't require having to set cookies through the params. Isn't this a bug then?
I think maybe the underlying issue is that we expect pwmetrics
to merge CLI flags with flags found in the config file. Indeed I believe that was the intention of this code:
https://github.com/paulirish/pwmetrics/blob/f8a784fd6930a1e8b79c1a00e7cd129178638edf/bin/cli.js#L86-L87
However, Object.assign()
is not actually merging those flag objects, it's merging the top level object and so cliFlags
gets replaced by config.flags.
If indeed the expectation is to merge these flags, it's a bug. I believe it's a relatively straightforward fix, and will submit a PR shortly.