A Mocha plugin that generates coverage data for CircleCI's Smarter Testing.
This plugin uses the v8 JS engine Profiler APIs to collect coverage.
Install the plugin.
pnpm add -D jsr:@circleci/mocha-circleci-coverageAdd the custom hook to the .mocharc.js file:
module.exports = {
require: ['@circleci/mocha-circleci-coverage'],
};Run tests with the CIRCLECI_COVERAGE env to collect coverage.
CIRCLECI_COVERAGE=coverage.json mochaInstall and use current node version.
NODE_VER=$(cat ./.nvmrc)
nvm install $NODE_VER
nvm use $NODE_VERInstall dependencies with pnpm.
pnpm installBuild the plugin.
pnpm buildRun tests.
pnpm test