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

escover

v4.3.0

Published

Coverage for EcmaScript Modules

Downloads

924

Readme

🎩ESCover License NPM version Build Status Coverage Status

Coverage for EcmaScript Modules based on 🐊Putout and loaders.

Why another coverage tool?

When you want to use ESM in Node.js without transpiling to CommonJS (that's what jest, ava, tap does), you have a couple problems to solve.

🤷‍ What test runner does no transpiling to CommonJS?

☝️ that's easy! 📼 Supertape supports ESM from the box;

🤷‍ How to mock modules without mock-require (we in ESM!);

☝️ that's solved! mock-import does the thing using loaders;

🤷‍ How to get coverage when nyc doesn't supported?

☝️ c8 could help, but no it supports no query parameters which are needed to load module again, and apply mocks.

🤷‍ How to get coverage when mocks are used?

☝️ Use 🎩ESCover! It supports loaders, ESM and collects coverage as a loader!

🤷‍ What with coveralls? Does lcov supported?

☝️ Sure! coverage/lcov.info is main coverage file for 🎩ESCover.

Install

npm i escover -D

Run to collect and show coverage:

escover npm test

Comparison with c8

Check out the real example from wisdom. There is next uncovered code:

import jessy from 'jessy';

export default (info) => typeof jessy('publishConfig.access', info) === 'undefined';

c8 shows three columns with 100% and one with 0%.

And here is what you will see with 🎩ESCover:

So if you need more accurate code with no bullshit green 100%, use 🎩ESCover 😉.

Config

exclude section of configuration file .nyrc.json supported.

How it looks like?

When everything is covered:

image

What formatters exists?

There is two types of formatters:

  • lines adds links to each line;
  • files shows information in table;

You can choose formatter with ESCOVER_FORMAT env variable.

What if I want to use 🎩ESCover with mock-import?

mock-import is used by default in 🎩ESCover.

Install it with:

npm i escover

Then run:

escover npm test

This is the same as:

NODE_OPTIONS="'--loader zenlend'" ZENLOAD='escover,mock-import' escover npm test

Env

If you want to disable coverage on status code without erroring, use ESCOVER_SUCCESS_EXIT_CODE:

import {SKIPED} from 'supertape/exit-codes';

const env = {
    ESCOVER_SUCCESS_EXIT_CODE: SKIPED,
};

export default {
    test: () => [env, `escover tape 'test/**/*.js' 'lib/**/*.spec.js'`],
};

What should I know about lcov?

Format used by 🎩ESCover located in coverage/lcov.info.

  • ☝️ lcov was created in 2002, twenty years ago.
  • ☝️ Linux kernel developers created it to know what is going on with the coverage.
  • ☝️ It's written in PERL and has text based format.
  • ☝️ This is most popular coverage format of all times supported by a lot of tools (like coveralls).

When you run your ESM application with:

escover npm test

You will receive something similar to:

SF:/Users/coderaiser/escover/lib/transform.js
DA:1,1
DA:3,1
DA:7,1
DA:9,1
DA:10,1
DA:12,1
DA:24,1
DA:25,1
DA:27,1
DA:28,1
DA:29,1
DA:32,1
end_of_record

Where:

  • SF - is path to source;
  • DA - is line number, and count of running;
  • end_of_record latest recorded for current file entry;

The only thing that is differ from lcov: counters are 0 or 1, if you have a reason to use "real" counters create an issue.

It can be added in one line of code, but I see no reason why it can be useful 🤷‍♂️.

License

MIT