npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lean-coverage-listener

v0.0.18

Published

Light agent for coverage collection using Node V8 Coverage

Downloads

192

Readme

Leightweight agent

Light agent for coverage collection using Node V8 Coverage

Configuration

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_

Default values

| Name | Default value | |--------------------|----------------| | tokenFile | sltoken.txt | | buildSessionIdFile | buildSessionId | | projectRoot | process.cwd(); |

Usage

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

Run in the same process

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 sidecar

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