GoogleChrome / lighthouse-ci

Automate running Lighthouse for every commit, viewing the changes, and preventing regressions
Apache License 2.0
6.41k stars 644 forks source link

Use `finalDisplayedUrl` to identify reports #887

Open chaimabg opened 1 year ago

chaimabg commented 1 year ago

Describe the bug I am running lighthouse-ci on two different URLs ( 'https://localhost:3000/Portal/#/Login' & 'https://localhost:3000/Portal/#/Dashboard') . The two generated reports (json file in .lighthouseci folder) have the same final URL ('https://localhost:3000/Portal/'). Only one report is showed on Lighthouse server (for this URL: 'https://localhost:3000/Portal/').

Expected behavior Final URL and requested URL should have the same value. Two reports are showed on lighthouse server ('https://localhost:3000/Portal/#/Login' & 'https://localhost:3000/Portal/#/Dashboard').

Configuration file

module.exports = {
    ci: {
        collect: {
            headful: true, 
            url:  [
                'https://localhost:3000/Portal/#/Login',
                'https://localhost:3000/Portal/#/Dashboard',
          ],
           puppeteerScript: 'authScript.js',  // Ensure there's an authenticated user before running Lighthouse for the second url
           puppeteerLaunchOptions: {
                defaultViewport: null,
            },
            numberOfRuns: 1, 
            settings: {
                disableStorageReset: true,
                preset: 'desktop',
                onlyCategories: ['performance'],
            }
        },
        upload: {
            target: 'lhci',
            serverBaseUrl: 'http://127.0.0.1:9001/',
            token: 'token', // the build token provider by the wizard. 
        }
    }
}

Reports

{
  "lighthouseVersion": "9.6.8",
  "requestedUrl": "https://localhost:3000/Portal/#/Login",
  "finalUrl": "https://localhost:3000/Portal/",
  "fetchTime": "2023-03-16T15:25:31.825Z",
  "gatherMode": "navigation",
  "runWarnings": [
    "The page may not be loading as expected because your test URL (https://localhost:3000/Portal/#/Login) was redirected to https://localhost:3000/Portal/. Try testing the second URL directly."
  ],...
}
{
  "lighthouseVersion": "9.6.8",
  "requestedUrl": "https://localhost:3000/Portal/#/Dashboard",
  "finalUrl": "ttps://localhost:3000/Portal/",
  "fetchTime": "2023-03-16T15:26:03.752Z",
  "gatherMode": "navigation",
  "runWarnings": [],...
}

Lighthouse Version 9.6.8

Environment (please complete the following information):

vilanint7 commented 1 year ago

@chaimabg , have you tried using the urlreplacementpatterns, https://github.com/GoogleChrome/lighthouse-ci/blob/75f4bb8f66d5042989f3882683c0e843677dda06/docs/configuration.md#urlreplacementpatterns

I have a similar problem and was planning to use urlreplacementpatterns

chaimabg commented 1 year ago

@vilanint7, yes I have tried to use urlreplacementpatterns but didn't work for my case. This problem is fixed with lighthouse version 10.0.2 but unfortunately lighthouse-ci works only with the version 9.6.8

vilanint7 commented 1 year ago

Thanks @chaimabg do you get an error when lighthouse version is higher? What is the error you get?

Below are my versions

lhci --version 0.8.2 lighthouse --version 7.4.0

Based on the dockerfile it looks like higher version of lighthouse should be supported https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/recipes/docker-client/Dockerfile#L17

there seems to be a related pr https://github.com/GoogleChrome/lighthouse-ci/pull/890

chaimabg commented 1 year ago

@vilanint7, no I don't get an error when lighthouse version is higher. I'm using the latest version of lhci (0.11.0) but doesn't support lighthouse version 10.0.2.

adamraine commented 1 year ago

As proposed in #900 the solution here is to use finalDisplayedUrl to identify reports. This cannot be backported for reports generated by Lighthouse version below 10.0.

tiagomrm commented 5 months ago

Any news on this issue? Did you find a workaround?