Add instrumentation for test coverage#28
Conversation
Added Node.js engine requirement and nyc configuration.
Add comments to clarify the purpose of the closure.
Removed unused path module import.
|
Why? It's not so important in tests, but storing and accessing stuff on |
|
I bypassed the vm just for testing coverage. For the sake of consistency, I'll change |
|
If you change A feature of c8 is that it has good defaults. Going from memory, I think nearly all of your c8 config is the default. If you add your desired reporter on the CLI (
The dkim plugin. We overload |
FWIW, I forked a copy of the DKIM plugin, modified it to use |
Conditionally inject plugin module for coverage tracking.
|
Coverage testing now uses c8 and it is only loaded when testing coverage. |
| "prettier": "npx prettier . --check", | ||
| "prettier:fix": "npx prettier . --write --log-level=warn", | ||
| "test": "node --test", | ||
| "test:coverage": "HARAKA_COVERAGE=1 npx c8 npm test", |
There was a problem hiding this comment.
Before I moved coverage testing into a GitHub action, I did initiate the convention of npm run cover and dropped that into a few plugins:
➜ grep cover `ghfind` | grep package.json
./plugin/dovecot/package.json: "coveralls": "DOVECOT_COVERAGE=1 npx mocha --require blanket --reporter mocha-lcov-reporter | npx coveralls.js",
./plugin/geoip/package.json: "cover": "NODE_ENV=cov npx nyc --reporter=lcovonly npm run test",
./plugin/log-reader/package.json: "cover": "npx istanbul cover npm test",
./plugin/known-senders/package.json: "cover": "npx nyc --reporter=lcov --hook-run-in-context npm run test",
./plugin/p0f/package.json: "cover": "NODE_ENV=cov npx nyc --reporter=lcovonly npm run test",
I like the clarity of the test:coverage name. I also like the finger friendliness of 'cover'. I'm not going to police what script names folks use in their Haraka plugins (like the dovecot plugin above) but if we're making suggestions to authors, I prefer them to be consistent. If you feel strongly about using test:coverage, this PR should be paired with:
- updating at least the script name in the other plugins
- preferably updating the script name and invocation to use c8
- extra credit: getting the coverage testing in each module to work
Changes proposed in this pull request:
Checklist: