-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[Feature] support test coverage for component testing #14511
Comments
Playwright is awesome for e2e and is going to be the same for component tests as well. |
have any update? I'm looking forward to getting coverage in a svelte project using playwright |
Now our team want to use playwright component testing replace unit tests for ui components, we think code coverage report such as provided by jest is a very important feature. |
Related to #7030 |
it's not working for projects which are not based on babel, there are webpack and CRA (create-react-app) |
Just implemented the code coverage report to monocart-reporter Preview coverage report: Using class-coverage API to collect V8 coerage data, so it's chromium only but supported both JS and CSS Related to #22953 |
Thanks to Coverage Class, we are able to generate coverage for our e2e testing. @stevez we too felt the same, so we decided to remove unit tests and replace them with component tests. So we need to generate coverage for both unit and component tests, merge, and push to quality gate, Our application consists of unit tests using Jest and component tests using Playwright, and when we try to merge the code coverage generated by both tools using nyc we are facing the following problem. We have a file that has 37 functions, one arrow function, one function that has two nested functions, and the remaining are normal functions. When we generate coverage for this file, the count in fnMap is not matching in both json. A function that has two nested functions is considered one single function in component coverage, with unit test it is considered three functions. Since count is not matching, nyc not able to merge. It's just appending. |
@raju-a, are you using playwright coverage class?(https://playwright.dev/docs/api/class-coverage), I believe this is using v8 coverage, I wonder if you also using v8 in jest instead of istanbul. If jest is using istanbul and playwright is using v8, then the merge is not going to work |
I am wondering if PW has a way to instrument the code using Istanbul and not relying on v8 coverage. |
@stevez @Tallyb Thanks a lot ! You guys are right! I didn't specify coverageProvider so it took babel as default. After adding In more detail to that file has 37 functions, one arrow function, one function that has two nested functions, and the remaining are normal functions. |
Do we have a test coverage tool for Playwright-Experimental-React Component test automation? I tried with @mxschmitt https://github.com/mxschmitt/playwright-test-coverage/tree/main but unfortunately it returns empty folder .nyc_output after execution. baseFixtures.ts covers page, context. But for components, mount is under the hood and unsure how to handle it. Any suggestions please ? |
I got code coverage working for react using the example repo from @cenfun https://github.com/cenfun/playwright-ct-vue by just changing any imports from vue to react. |
I feel component testing can replace most of the unit tests, so it would be nice if component testing can support test coverage
Update by maintainers
Following this guide, should make it work for component testing.
The text was updated successfully, but these errors were encountered: