Skip to content

Enhancement: Generate test coverage reports after npm test (#2289) #2294

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

Closed
wants to merge 8 commits into from

Conversation

JesseCodeBones
Copy link
Contributor

Signed-off-by: Jesse [email protected]

Issue details: #2289

Test report screen shot:
image

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@HerrCai0907
Copy link
Member

@dcodeIO @MaxGraey. I think add coverage is helpful during feature development. wdyt?

package.json Outdated
Comment on lines 74 to 76
"coverage": "ASC_FEATURES=\"*\" c8 npm run test:coverage",
"test": "npm run test:parser && npm run test:compiler -- --parallel && npm run test:browser && npm run test:asconfig && npm run test:transform",
"test:coverage": "npm run test:parser && npm run test:compiler && npm run test:browser && npm run test:asconfig && npm run test:transform",
Copy link
Member

@dcodeIO dcodeIO Sep 21, 2022

Choose a reason for hiding this comment

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

Looks like the test:coverage step can be included in coverage as it isn't very useful on its own. Even better perhaps, if the test step could detect that it runs under c8 (looking at process.argv or .env perhaps) and then disables parallel execution - so the test step can be reused? Then we'd have

  "coverage": "ASC_FEATURES=\"*\" c8 npm test",

A minor concern could be that sometimes, ASC_FEATURES can enable things that are not yet fully functioning, so setting it independently could make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Dcode,
Considering the compatibility of Windows and POSIX system. I prefer the process.argv. currently the issue is, c8 need a something like zygote process process, so it cannot use && on its command line.
So I create coverage and test:coverage tasks, the test:coverage will have --coverage option for specific test test:compiler
The other option is we can create a test.js file and use it to control the environment variables and argument variables, with this option, we only need one coverage task.
What do you think?
Regards

Copy link
Member

@dcodeIO dcodeIO Sep 22, 2022

Choose a reason for hiding this comment

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

Toying around with c8 a little, I found that instead of having a separate --coverage option, we can detect that c8 is being used by checking process.env.NODE_V8_COVERAGE != null and then turn off parallel testing. Looks like this allows to reuse the test step?

(found this here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dcodeIO
yes, we can use this option, I finished the modification

@JesseCodeBones JesseCodeBones force-pushed the Issue-2289 branch 2 times, most recently from 6e0a99d to 5cf3e68 Compare September 22, 2022 08:29
@@ -501,7 +504,7 @@ function evaluateResult(failedTests, skippedTests) {
}

// Run tests in parallel if requested
if (args.parallel && coreCount > 2) {
if (args.parallel && coreCount > 2 && !args.coverage) {
Copy link
Member

Choose a reason for hiding this comment

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

For example here:

Suggested change
if (args.parallel && coreCount > 2 && !args.coverage) {
const isCoverage = process.env.NODE_V8_COVERAGE != null;
if (args.parallel && coreCount > 2 && !isCoverage) {

@dcodeIO dcodeIO mentioned this pull request Sep 22, 2022
2 tasks
@dcodeIO
Copy link
Member

dcodeIO commented Sep 22, 2022

The slightly modified PR above is based on this PR with a few slight changes so coverage remains light / optional for now. One would manually set ASC_FEATURES, and c8 is installed on demand, whereas all the necessary configuration is provided. PTAL :)

@dcodeIO
Copy link
Member

dcodeIO commented Sep 23, 2022

Initial code coverage in the spirit of this PR has been added in #2517, with the difference that it is kept optional for now. Sorry for the strange co-authored-by in the commit message, I used the signed-off credentials from the first post that apparently link to a different account, hrm.

@dcodeIO dcodeIO closed this Sep 23, 2022
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

Successfully merging this pull request may close these issues.

3 participants