Skip to content

Commit

Permalink
chore: replaces c8 with node native coverage (#46)
Browse files Browse the repository at this point in the history
## Description

- replaces c8 with node 'native' --experimental-test-coverage

## Motivation and Context

c8 in our setup always returned 100% coverage for all things - which
might have to do with an issue in tsx (see [tsx
#433](privatenumber/tsx#433) ), but might just
as well be caused by something unexpectedly breaking in de nodejs / v8
w.r.t. loader coverage.

`--experimental-test-coverage` is not perfect either (i.c.w. tsx it's
unstable on node > 20.12.2, and line numbers are off), but at least the
coverage data we get is more realistic.

## How Has This Been Tested?

- [x] green ci

## Screenshots

```
> tsx --experimental-test-coverage --test-reporter ./tools/dot-with-summary.reporter.js --test src/*.spec.ts src/**/*.spec.ts

.................................................

49 passing (1.420 ms)

=============================== Coverage summary ===============================
Branches     : 97,89 % (93/95) NOK
Functions    : 100 % (38/38)
Lines        : 99,76 % (422/423)
================================================================================

Uncovered lines:
  /Users/sander/prg/js/watskeburt/src/git-primitives.ts:80

Uncovered branches:
  /Users/sander/prg/js/watskeburt/src/git-primitives.ts:79
  /Users/sander/prg/js/watskeburt/src/main.ts:22
```

## Types of changes

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Documentation only change
- [ ] Refactor (non-breaking change which fixes an issue without
changing functionality)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] Chore
  • Loading branch information
sverweij committed May 12, 2024
1 parent 93850d9 commit fdbe28e
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 487 deletions.
8 changes: 0 additions & 8 deletions .c8rc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
},
overrides: [
{
files: ["**/*.ts"],
files: ["**/*.ts", "**/*.js"],
rules: {
"unicorn/no-null": "off",
"unicorn/prefer-spread": "off",
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
matrix:
node-version:
- 18.x
- 20.12.2
- 22.x
platform:
- ubuntu-latest
Expand Down Expand Up @@ -59,16 +60,20 @@ jobs:
if: matrix.node-version == env.NODE_LATEST
- run: npm run lint
if: matrix.node-version == env.NODE_LATEST
- run: npm run test:cover
if: matrix.node-version == env.NODE_LATEST
# - run: npm run test:cover
# if: matrix.node-version == env.NODE_LATEST
- run: npx tsx --test src/*.spec.ts src/**/*.spec.ts
if: matrix.node-version == '18.x'
if: matrix.node-version == '18.x' || matrix.node-version == env.NODE_LATEST
- run: npm run build
- name: emit coverage results to step summary
if: always() && matrix.node-version == env.NODE_LATEST
# specifically version 20.12.2 as that's the latest node version where
# coverage reporting (in our setup, with tsx) is still stable.
if: always() && matrix.node-version == '20.12.2'
run: |
echo '## Code coverage' >> $GITHUB_STEP_SUMMARY
npx tsx tools/istanbul-json-summary-to-markdown.ts < coverage/coverage-summary.json >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
npx tsx --experimental-test-coverage --test-reporter ./tools/dot-with-summary.reporter.js --test src/*.spec.ts src/**/*.spec.ts >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: emit full depcruise results to step summary
if: always() && matrix.node-version == env.NODE_LATEST
run: |
Expand Down

0 comments on commit fdbe28e

Please sign in to comment.