
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
lean-coverage-listener
Advanced tools
Light agent for coverage collection using Node V8 Coverage
Cli argument can’t be used directly with a lightweight agent. It should be passed via file sl.conf file or via env var.
Env var should be prefixed by SL_
Name | Default value |
---|---|
tokenFile | sltoken.txt |
buildSessionIdFile | buildSessionId |
projectRoot | process.cwd(); |
Preloader script should be injected/installed beforehand. For example, into ./agent/lightweight.js
Define execution of lightweight agent before main script by setting env var NODE_OPTIONS="-r <path to agent>"
for instance NODE_OPTIONS="-r ./node_modules/lean-coverage-collector/preloader.js"
When you need define folder where coverage footprints will be stored. You can provide NODE_V8_COVERAGE env. Otherwise, default folder .sl-cov will be used.
By default, coverage listener will be executed in a child process but it can be configured
Env var SL_IN_PROCESS_COVERAGE_COLLECTION
can be passed to run coverage listener in a same process with tested app. Also if you want everything to be executed in one process you also need to pass NODE_V8_COVERAGE explicitly. Otherwise, app will be executed in a separate process.
It will cause sending of extra hits because internal hits from agent will be sent. But it won't have impact on coverage accuracy.
Run in a sidecar allow to collect coverage from other processes via file system (even more from one at once). To do that agent should be started directly like npx lean-coverage-collector
. For correct work it require env NODE_V8_COVERAGE
to be defined. Also all processes that will provide coverage should call method v8.takeCoverage()
periodically.
To achive that, process can be executed with preloader and option SL_SKIP_PRELOADER=1
. In that case preloader main logic won't be executed but will be defined a timer to take coverage each 10 sec. It will prevent execution of preloader script and will set a timer for coverage snapshots generation.
WARN: Usage of preloader without SL_SKIP_PRELOADER=1
parameter will create new instance of agent that will conflict with a sidecar instance
Also separate script ./node_modules/lean-coverage-collector/coverage-collector.js
can be used. Just run it before execution via -r
option
Another option is to modify the itself and add import of coverage-collector.js
or just add next code:
cosnt v8 = require('v8');
const timer = setInterval(() => {
log('Get coverage');
v8.takeCoverage();
}, +process.env['SL_COVERAGE_INTERVAL']);
timer.unref();
Example: Run of agent in a sidecar
export NODE_V8_COVERAGE=.sl-cov
npx lean-coverage-collector
OR
node ./node_modules/lean-coverage-collector/runner.js
Run of observable process
export NODE_V8_COVERAGE=.sl-cov
export SL_SKIP_PRELOADER=1
node -r ./node_modules/lean-coverage-collector/preloader.js ./dist/server.js
or
export NODE_V8_COVERAGE=.sl-cov
node -r ./node_modules/lean-coverage-collector/coverage-collector.js ./dist/server.js
FAQs
Light agent for coverage collection using Node V8 Coverage
We found that lean-coverage-listener demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.