nodejs.org icon indicating copy to clipboard operation
nodejs.org copied to clipboard

feat(learn): Collecting code coverage

Open avivkeller opened this issue 1 year ago • 9 comments

Description

This PR introduces a learning article on collecting code coverage in Node.js. However, it should not be merged until support for thresholds is included in the next semver-minor release, which is expected to be next week.

Related Issues

Support for code coverage: https://github.com/nodejs/node/pull/46017 Support for code coverage inclusion/exclusion: https://github.com/nodejs/node/pull/53553 Support for code coverage thresholds: https://github.com/nodejs/node/pull/54429

Check List

  • [x] I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • [x] I have run npm run format to ensure the code follows the style guide.
  • [x] I have run npm run test to check if all tests are passing.
  • [x] I have run npx turbo build to check if the website builds without errors.
  • [N/A] I've covered new added functionality with unit tests if necessary.

avivkeller avatar Aug 24 '24 15:08 avivkeller

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Mar 22, 2025 1:36pm

vercel[bot] avatar Aug 24 '24 15:08 vercel[bot]

This is currently marked as draft until the next semver-minor release of Node.js

avivkeller avatar Aug 24 '24 15:08 avivkeller

https://nodejs-org-git-fork-redyetidev-code-coverage-learn-openjs.vercel.app/en/learn/test-runner/collecting-code-coverage

avivkeller avatar Aug 24 '24 15:08 avivkeller

Deployment failed with the following error:

The provided GitHub repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.

vercel[bot] avatar Aug 24 '24 17:08 vercel[bot]

I've undrafted this, as the release proposal for v22.8.0 is ready at https://github.com/nodejs/node/pull/54560, but it still shouldn't land until that does.

The expected release date is ~~2024-08-26~~ 2024-09-02

avivkeller avatar Aug 25 '24 23:08 avivkeller

Unit Test Coverage Report

Lines Statements Branches Functions
Coverage: 90%
88.75% (742/836) 76.1% (242/318) 87.65% (142/162)

Unit Test Report

Tests Skipped Failures Errors Time
182 0 :zzz: 0 :x: 0 :fire: 6.096s :stopwatch:

github-actions[bot] avatar Aug 26 '24 07:08 github-actions[bot]

Can we have last review form @nodejs/test_runner

AugustinMauroy avatar Sep 02 '24 15:09 AugustinMauroy

I think this is okay to land once v22.8.0 releases, as it specifies that the --experimental-code-coverage command is needed, indicating that it is experimental. Would you like me to add a notice at the beginning that this is experimental, or just hold off until it's stabilized?

avivkeller avatar Sep 02 '24 17:09 avivkeller

I think it's better to hold off until it's stable.

mcollina avatar Sep 02 '24 17:09 mcollina

Is there an ETA for the stabilization of it?

ovflowd avatar Oct 28 '24 21:10 ovflowd

IMO code coverage (w/o the --enable-source-maps flag) is pretty stable. I haven't seen many bugs with it in a while.

I asked a few weeks ago, and it was pointed out that statement coverage isn't supported, however, I'm not sure if that's in the plans for the immediate future of code coverage.

The original issue tracking the stability has been closed as completed, as all tasks were completed, which might mean it's ready to be stable. I've left a comment asking.

avivkeller avatar Oct 28 '24 22:10 avivkeller

I'm fine keeping this open for the meantime, the problem is it becoming stale.

ovflowd avatar Nov 17 '24 00:11 ovflowd

I'm also happy to close and reopen it, as chances are there will be some significant changes to the coverage reporter before stabilization, and this only collecting merge conflicts.

avivkeller avatar Nov 17 '24 01:11 avivkeller

It's still experimental, but it's more stable, so I also think this can be merged.

@mcollina are you still blocking?

(I'll resolve the conflicts later today)

avivkeller avatar Mar 22 '25 11:03 avivkeller

Lighthouse Results

URL Performance Accessibility Best Practices SEO Report
/en 🟢 93 🟢 100 🟢 100 🟢 91 🔗
/en/about 🟢 100 🟢 100 🟢 100 🟢 91 🔗
/en/about/previous-releases 🟢 100 🟢 100 🟢 100 🟢 92 🔗
/en/download 🟢 92 🟢 100 🟢 100 🟢 91 🔗
/en/blog 🟢 99 🟢 100 🟢 96 🟢 92 🔗

github-actions[bot] avatar Mar 22 '25 13:03 github-actions[bot]

Article published: https://nodejs.org/en/learn/test-runner/collecting-code-coverage

avivkeller avatar Mar 22 '25 13:03 avivkeller