[Testing:Developer] Code coverage for Component tests#12959
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12959 +/- ##
============================================
+ Coverage 21.35% 21.44% +0.09%
Complexity 9990 9990
============================================
Files 275 277 +2
Lines 37317 37361 +44
Branches 505 512 +7
============================================
+ Hits 7969 8013 +44
Misses 28847 28847
Partials 501 501
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
|
||
| return { | ||
| plugins, | ||
| define: { |
williamjallen
left a comment
There was a problem hiding this comment.
@jndlansh Please make sure coverage is turned on in CI:
|
Thanks @williamjallen, I have added code-coverage in CI, missed out initially. |
|
Now, shall I add Cypress code coverage to codecov? |
JManion32
left a comment
There was a problem hiding this comment.
As we discussed in our meeting, please add this to the codecov.yml file, and make sure to update the PR description accordingly.
I see you added several new dependencies to create this. I think it is good practice, especially if there are multiple, to explain the need for adding each of them. nyc and vite-plugin-istanbul especially caught my eye when I first looked over this PR. I looked into this a little bit, and they actually have an interesting history:
The original JavaScript coverage tool was called Istanbul (named after the city). When the maintainers rewrote and modernized the command-line interface, they named it nyc—another famous city, and the common abbreviation for New York City. - ChatGPT
And this is what each new dependency does:
vite-plugin-istanbulprepares the code for coverage.@cypress/code-coveragecaptures the coverage while Cypress runs.nycturns that captured data into reports you can read.
Just add something to the description so it is clear to other reviewers.
I noticed this in the CI output before the coverage report:
Opening Cypress...
Warning: The allowCypressEnv configuration option is enabled. This allows any browser code to read values from Cypress.env(). This is insecure and will be removed in a future major version.
1. Replace Cypress.env() calls with cy.env() (for sensitive values) or Cypress.expose() (for public configuration)
2. Set allowCypressEnv: false in your Cypress configuration to disable Cypress.env()
Learn more: https://on.cypress.io/cypress-env-migration
I verified this is new to this PR. Can we address it here?
|
Now for this warning that is displayed on CI/cypress component : I checked it on main branch and got this same warning in the terminal atleast |
Yes, you are correct, I just verified the same. |
JManion32
left a comment
There was a problem hiding this comment.
CodeCov is currently saying that the coverage is 100% for cypress-component. This is not possible, since the popup test is 28/29. I dug into this a bit, and it looks like this may be caused by the path you are using in codecov.yml. There are no Vue files at site/vue, so maybe you want to adjust that to site/vue/src or even site/vue/src/components?
I am not sure if this is the definite solution, but it is a good starting point. I just know that CodeCov shouldn't be reporting 100% since our only merged test is 28/29.
williamjallen
left a comment
There was a problem hiding this comment.
Seems reasonable to me. Good to merge, once @JManion32 is happy with the changes.



Why is this Change Important & Necessary?
Closes #12915
This PR adds code coverage for Cypress Component Tests, allowing developers to measure how much of the Vue component source code is exercised during testing. This helps identify untested code paths, improves confidence in new component tests, and provides visibility into frontend test coverage.
What is the New Behavior?
New dependencies introduced with this PR :
Running Component Tests with:
VITE_COVERAGE=true npx cypress run --componentnow generates coverage information, including HTML and lcov reports.
Normal development (vite) and production builds (npm run build) continue to behave exactly as before and are not instrumented.
What steps should a reviewer take to reproduce or test the bug or new feature?
Automated Testing & Documentation
Other information