Skip to content

[Testing:Developer] Code coverage for Component tests#12959

Merged
bmcutler merged 18 commits into
Submitty:mainfrom
jndlansh:code-coverage
Jul 3, 2026
Merged

[Testing:Developer] Code coverage for Component tests#12959
bmcutler merged 18 commits into
Submitty:mainfrom
jndlansh:code-coverage

Conversation

@jndlansh

@jndlansh jndlansh commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

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?

  • Enables coverage in CI
  • Uploads the reports to Codecov
  • Adds a dedicated cypress-component Codecov flag
  • Surfaces the coverage directly in the PR comment
image

New dependencies introduced with this PR :

  1. vite-plugin-istanbul prepares the code for coverage.
  2. @cypress/code-coverage captures the coverage while Cypress runs.
  3. nyc turns that captured data into reports you can read.

Running Component Tests with:

VITE_COVERAGE=true npx cypress run --component
Screenshot 2026-06-26 010140

now 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?

  1. Sync changes and install dependencies if required
  2. Run Cypress Component Tests with coverage enabled:
In bash: 
VITE_COVERAGE=true npx cypress run --component
or 
VITE_COVERAGE=true npx cypress open --component
  1. Verify that:

Component tests pass successfully.
Coverage is collected and summarized in the terminal.
Coverage reports are generated in the coverage/ directory.

Automated Testing & Documentation

  1. Verified successful production build.
  2. Verified Cypress Component Tests pass with coverage enabled.
  3. Verified coverage reports are generated successfully.
  4. Confirmed that instrumentation is only enabled when VITE_COVERAGE=true is set.

Other information

  1. Not a Breaking change
  2. No Migrations needed.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 21.44%. Comparing base (01f8919) to head (8875d3d).

Additional details and impacted files

Impacted file tree graph

@@             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              
Flag Coverage Δ
autograder 21.16% <ø> (ø)
js 1.98% <ø> (ø)
migrator 100.00% <ø> (ø)
php 20.41% <ø> (ø)
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 91.13% <ø> (ø)
vue 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jndlansh
jndlansh requested a review from JManion32 June 26, 2026 03:53
@automateprojectmangement automateprojectmangement Bot moved this from Seeking Reviewer to In Review in Submitty Development Jun 26, 2026
Comment thread site/vue/vite.config.mts Outdated

return {
plugins,
define: {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation

@williamjallen williamjallen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jndlansh Please make sure coverage is turned on in CI:

Image

@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Jun 27, 2026
@jndlansh

Copy link
Copy Markdown
Contributor Author

Thanks @williamjallen, I have added code-coverage in CI, missed out initially.
Screenshot 2026-06-27 100002

@jndlansh

Copy link
Copy Markdown
Contributor Author

Now, shall I add Cypress code coverage to codecov?

@jndlansh
jndlansh requested a review from williamjallen June 27, 2026 17:05
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Jun 27, 2026
Comment thread .gitignore Outdated

@JManion32 JManion32 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. vite-plugin-istanbul prepares the code for coverage.
  2. @cypress/code-coverage captures the coverage while Cypress runs.
  3. nyc turns 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?

Comment thread .gitignore Outdated
@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Jun 29, 2026
@jndlansh

jndlansh commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Now for this warning that is displayed on CI/cypress component :
I don't think it is not caused by the code coverage changes. I removed the @cypress/code-coverage/support import and the warning still appears. Would like to know your opinion.

I checked it on main branch and got this same warning in the terminal atleast

@jndlansh
jndlansh requested a review from JManion32 June 29, 2026 19:05
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Jun 29, 2026
@JManion32

Copy link
Copy Markdown
Contributor

Now for this warning that is displayed on CI/cypress component : I don't think it is not caused by the code coverage changes. I removed the @cypress/code-coverage/support import and the warning still appears. Would like to know your opinion.

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 JManion32 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Jun 29, 2026
Comment thread .codecov.yml Outdated
Comment thread .codecov.yml
Comment thread .codecov.yml Outdated
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Jun 30, 2026

@williamjallen williamjallen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me. Good to merge, once @JManion32 is happy with the changes.

@JManion32 JManion32 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code coverage now displays for each test and is a part of CodeCov.

We currently have 2:

Popup
Image

StatusBanner
Image

This will be helpful for ensuring our component tests are thorough. Nice work!

@github-project-automation github-project-automation Bot moved this from In Review to Awaiting Maintainer Review in Submitty Development Jul 2, 2026
@bmcutler
bmcutler merged commit a67bbb7 into Submitty:main Jul 3, 2026
25 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Set up code coverage for Cypress component tests

4 participants