Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,34 @@ jobs:
run: npm run typecheck
- name: Run tests
run: npm test

test-coverage:
name: Test coverage
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set up Node.js
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: '26.x'
cache: 'npm'
- name: Install npm dependencies
run: npm install
- name: Report coverage
run: |
set -o pipefail
npm run test:coverage | tee "$RUNNER_TEMP/coverage.txt"
{
echo '## Test coverage'
echo
echo '```'
awk '/start of coverage report/{f=1;next} /end of coverage report/{f=0} f' "$RUNNER_TEMP/coverage.txt" | sed 's/^ℹ //'
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage
path: coverage/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# JSDoc
/docs

# Test coverage
/coverage
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ code in this repository.
- `npm test` — run the test suite (uses Node's built-in `node --test` runner;
tests live next to source as `*.test.js`).
- `npm test -- --watch` — re-run tests on file change.
- `npm run test:coverage` — run the suite with coverage, printing a report and
writing `coverage/lcov.info`. CI runs this in a separate job that posts the
report to the run summary and uploads it as an artifact. There is no
threshold: coverage is reported, not enforced.
- `node --test src/main.test.js` — run a single test file. Add
`--test-name-pattern '<regex>'` to filter by test name.
- `npm run lint` — Prettier format check + ESLint. `npm run lint:format:fix` and
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
"lint:format:fix": "prettier --write .",
"lint:quality": "eslint .",
"lint:quality:fix": "eslint --fix .",
"pretest:coverage": "node -e \"require('node:fs').mkdirSync('coverage', { recursive: true })\"",
"release": "release-it --only-version",
"test": "node --test",
"test:coverage": "node --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info",
"typecheck": "tsc"
},
"devDependencies": {
Expand Down