4.1.0 β€’ Published 3 months ago

escover v4.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

🎩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

4.1.0

3 months ago

4.0.1

5 months ago

4.0.0

5 months ago

3.8.1

6 months ago

3.8.0

7 months ago

3.7.0

8 months ago

3.6.1

8 months ago

3.6.0

8 months ago

3.5.2

9 months ago

3.5.1

9 months ago

3.5.0

9 months ago

3.4.0

11 months ago

3.3.1

11 months ago

3.3.0

12 months ago

3.3.2

11 months ago

3.2.2

1 year ago

3.2.1

1 year ago

3.2.0

1 year ago

3.2.4

12 months ago

3.2.3

12 months ago

3.0.0

1 year ago

2.5.3

1 year ago

3.1.2

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

2.5.2

1 year ago

2.5.1

2 years ago

2.2.0

2 years ago

2.4.0

2 years ago

2.3.0

2 years ago

2.1.2

2 years ago

2.5.0

2 years ago

2.3.1

2 years ago

2.1.3

2 years ago

2.1.1

2 years ago

2.0.2

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.20.2

2 years ago

1.20.1

2 years ago

1.20.0

2 years ago

1.19.0

2 years ago

1.18.0

2 years ago

1.17.2

2 years ago

1.17.1

2 years ago

1.17.0

2 years ago

1.16.0

2 years ago

1.15.0

2 years ago

1.14.0

2 years ago

1.13.0

2 years ago

1.12.0

2 years ago

1.11.0

2 years ago

1.10.0

2 years ago

1.9.0

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.2

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago