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

[question]: The plugin works for e2e test coverage, but can not combine the unit test coverage result #29

Closed
stevez opened this issue Apr 8, 2022 · 7 comments

Comments

@stevez
Copy link

stevez commented Apr 8, 2022

  1. The plugin works when I use playwright e2e test framework on the vite server, the coverage result is very close to the webpack + babel plugin;
  2. My unit tests is using mocha + babel istanbul plugin + nyc,
  3. when I tried to merge the coverage results from both 1) and 2), the overall result is wrong.

I wonder how could I resolve this? I noticed the json file using your plugin includes the sourcemap, but my unit tests result do not have them, do you think this might cause the issue? and how can I include the source map in unit tests coverage?

@iFaxity
Copy link
Owner

iFaxity commented Apr 8, 2022

Hi @stevez, this is weird indeed and not something i've run into before.

I'll see what i can find, however this is probably not anything related to this plugin rather in how code-coverage reporters works. Or rather the code-coverage merger.

It's also really hard to understand/debug without having any of the data of how the coverage files looks like.

@yann-combarnous
Copy link

@stevez , I think you run into the same issue as I do, see #28 .

@stevez
Copy link
Author

stevez commented Apr 17, 2022

I finally find a workaround: I used babel istanbul plugin inside the vite react plugin, for example in vite.config.js

plugins: [
    react(
      {
        babel: {
            plugins: [
                ["istanbul"],
            ],
        },
    }
    ),
  ],

I found this solution in the stackoverflow, it is a very smart trick.
Since my unit tests are instrumented by using babel istanbul plugin, in this way both unit tests and playwright tests are using the same way for the instrument, the 2 tests coverage merging works finally.

@stevez stevez closed this as completed Apr 17, 2022
@stevez
Copy link
Author

stevez commented Apr 17, 2022

@stevez , I think you run into the same issue as I do, see #28 .

I feel it is a different issue, in my use case the coverage json file includes all the source files, it seems fine for me.

@stevez stevez reopened this Apr 17, 2022
@iFaxity
Copy link
Owner

iFaxity commented May 3, 2023

Closing as the original issue has a workaround

@iFaxity iFaxity closed this as completed May 3, 2023
@VasylQA
Copy link

VasylQA commented Jun 29, 2023

@stevez could you please share all configurations and setting of how you made E2E Playwright tests work with this plugin?
And how are you processing results?

@stevez
Copy link
Author

stevez commented Jun 29, 2023

@VasylQA, it ended up it didn’t use this plugin, here is how I used:
plugins: [
react(
{
babel: {
plugins: [
["istanbul"],
],
},
}
),
],

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

4 participants