cenfun / monocart-coverage-reports

A code coverage tool to generate native V8 reports or Istanbul reports.
MIT License
68 stars 6 forks source link

sourceFilter not triggered #10

Closed azamat-sharapov closed 6 months ago

azamat-sharapov commented 7 months ago

I just upgraded monocart-reporter from v2.2.2 to v2.4.4 and coverage.sourceFilter is not working anymore. I can see that entryFilter and sourcePath functions are triggered, but not sourceFilter. Is there something obvious I should check? or should I start creating repro?

cenfun commented 7 months ago

Not sure where the issue is, feel free to provide reproduction steps. Guessing, if there is no sourcemap for the entry file, sourceFilter will not be called.

azamat-sharapov commented 7 months ago

I forgot to mention, this is only happening with remote URL, such as https://my-test-website.example.com. Cannot reproduce it with localhost servers.

Here is one sample file from my build: https://pr-641.z8999f743.rustrocks.me/assets/Tel-iIzw_ewH.js and it has sourcemap as well: https://pr-641.z8999f743.rustrocks.me/assets/Tel-iIzw_ewH.js.map

Again, this was working in monocart-reporter version 2.2.2 but stopped working with 2.4.4.

cenfun commented 7 months ago

let me check with your js and map

cenfun commented 7 months ago

It unable to find a method to reproduce the issue, because the single js your provided can not run independently. Could you please provide a small repo for the reproduction? thanks.

cenfun commented 7 months ago

It seems that your sourcemap is strange, there is only one mapping. image

azamat-sharapov commented 7 months ago

@cenfun I have standard Vite setup, which you can inspect here (same repo I provided earlier for another issue).

cenfun commented 7 months ago

image I get two files, is it correct? What do you expect?

azamat-sharapov commented 7 months ago

@cenfun I showed you the repository just to check overall setup (Vite, playwright config). Because this is small version of what we have in private repository. Let's summarise this issue:

cenfun commented 7 months ago

OK, I understand. Could you please tell me how to set up a remote host to reproduce the issue? I need to debug the code to locate the issue. Or is there anything else that can help fix this issue?

azamat-sharapov commented 7 months ago

@cenfun remote would be to make a build and host it somewhere. Then run e2e test agains that remote domain. This might be little more work to do, that's why I was trying to find which version introduced this issue. I can confirm that it started happening from monocart-reporter version 2.3.3. It is working fine with version 2.3.2.

cenfun commented 7 months ago

Yes, the issue should be caused by latest version monocart-coverage-reports

So there are lots of changes. Could you please help to check the logs if any errors found in console with logging=debug?

[
      'monocart-reporter',
      {
        logging: "debug",
        title: 'Web App test report',
        coverage: {
           logging: "debug",
        },
      },
    ],
azamat-sharapov commented 7 months ago

@cenfun yeah, that's why I used pnpm's override functionality to override monocart-coverage-reports version and it worked fine with v2.5.6. (it starts breaking from v2.5.7).

image

So, monocart-reporter latest version (2.4.5) and monocart-coverage-reports older version (2.5.6) works together. However, I see some uncovered lines in coverage report, so I guess it's not good idea to mix those versions of libraries.

I will revert to latest versions of both libs and try with logging and let you know.

cenfun commented 7 months ago

it starts breaking from v2.5.7

Good to know it.
I checked the changes and found there is a change for loading the soucemap file may caused the issue. But still need a case to reproduce the issue. Is it works for following sourcemap? https://pr-641.z8999f743.rustrocks.me/assets/Tel-iIzw_ewH.js.map

azamat-sharapov commented 7 months ago

@cenfun I tried debugging, no errors. The version 2.5.6 works with Tel.vue file, yes:

image

cenfun commented 7 months ago

@azamat-sharapov I just release a new version monocart-coverage-reports@2.7.5, please try it and let me know if fix the issue?

By checking your soucemap file, its content type is not json, so it may caused the issue image

The right json content type should be Content-Type: application/json; charset=utf-8 You might need to set the content type to json for all .map files on your server.

azamat-sharapov commented 7 months ago

@cenfun this is working now 🎉 thanks a lot! I've deployed a change to adjust content type as well 👍🏻

azamat-sharapov commented 6 months ago

@cenfun unfortunately this is happening again (from version 2.7.6), sourceFilter function is not triggered. This time it's locally as well, not remote server. Node.js version 18.17.1.

cenfun commented 6 months ago

Could you please try Node v18.19.1? https://nodejs.org/dist/v18.19.1/ or Node 20+

azamat-sharapov commented 6 months ago

@cenfun thanks for fixing, it's working with latest version on monocart-reporter and sorry for late reply 🙏🏻