Detalhes do pacote

escover

coderaiser241MIT4.3.2

Coverage for EcmaScript Modules

coverage, putout, loader

readme (leia-me)

🎩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%.

image

And here is what you will see with 🎩ESCover:

image

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

changelog (log de mudanças)

2025.01.29, v4.3.2

feature:

  • 5b0baad escover: eslint-plugin-putout v24.0.0
  • fb23854 escover: putout v38.0.0

2024.12.13, v4.3.1

feature:

  • aa073d5 escover: putout v37.0.1

2024.10.27, v4.3.0

feature:

  • 5371048 escover: @putout/plugin-convert-optional-to-logical v4.0.0
  • c8f1128 escover: @putout/test v11.0.0
  • 35ac493 escover: putout v36.11.0
  • 0e4c521 escover: eslint-plugin-putout v23.2.0
  • ffbaffa escover: c8 v10.1.2

2024.06.07, v4.2.0

feature:

  • a14d18d escover: @putout/test v10.0.0
  • 1b1e4e9 escover: eslint v9.4.0
  • 21f9710 escover: picomatch v4.0.2

2024.01.29, v4.1.0

feature:

  • 51103b4 escover: find-up v7.0.0
  • 427406f escover: c8 v9.1.0
  • 0d53d2f escover: @putout/test v8.4.0
  • e6fde48 escover: eslint-plugin-putout v22.3.1
  • 4e58f46 escover: putout v35.0.1
  • f57fb20 escover: supertape v10.0.0

2023.12.10, v4.0.1

feature:

  • 98fd927 escover: mock-import v4.0.0

2023.12.10, v4.0.0

feature:

  • c365383 convert to node v18 loaders
  • cc25857 escover: drop support of node < 18
  • 7cc297d escover: madrun v10.0.0
  • 3513811 escover: putout v34.0.0

2023.11.09, v3.8.1

feature:

  • c5ac532 escover: putout v33.0.0
  • c3b1022 escover: eslint-plugin-putout v21.0.2

2023.10.02, v3.8.0

feature:

  • 403e522 package: @putout/plugin-convert-optional-to-logical v3.1.0
  • b2fe53e package: eslint-plugin-putout v20.0.0

2023.09.14, v3.7.0

feature:

  • 91c6066 package: putout v32.0.0

2023.08.27, v3.6.1

feature:

  • 7cb7e37 package: @putout/plugin-convert-optional-to-logical v2.0.0

2023.08.27, v3.6.0

feature:

  • 212cf40 package: find-cache-dir v5.0.0

2023.08.04, v3.5.2

feature:

  • 95cc7a5 package: eslint-plugin-putout v19.0.0
  • a2d2857 package: putout v31.0.0

2023.07.31, v3.5.1

fix:

  • ba6e405 escover: write coverage on exit -> write coverage each time

2023.07.31, v3.5.0

fix:

  • 2411d57 escover
  • 830082d escover: exit

feature:

  • b6b1301 package: @putout/test v7.0.1
  • e9502cc package: c8 v8.0.1
  • 882431a package: eslint-plugin-putout v18.2.0
  • eb15154 package: putout v30.7.0

2023.06.08, v3.4.0

feature:

  • 2a602d2 escover: expression

2023.06.08, v3.3.2

fix:

  • 2792d33 drop console.log

2023.05.31, v3.3.1

feature:

  • 9c0b9bb escover: loader: add

2023.05.26, v3.3.0

fix:

  • 18db2ed escover: cli

feature:

  • 5409caa package: eslint-plugin-n v16.0.0

2023.05.10, v3.2.4

fix:

  • 74c5607 escover: cli: add quotes to NODE_OPTIONS

2023.05.07, v3.2.3

fix:

  • f0e959e escover: add montag

2023.05.05, v3.2.2

feature:

  • 1123033 escover: improve node v20 support

2023.05.05, v3.2.1

feature:

  • 0c86858 escover: rm unused deps
  • 98ff5ae package: escover v3.2.0

2023.05.05, v3.2.0

feature:

2023.05.05, v3.1.2

feature:

  • 520372c escover: improve support of OptionalChaining

2023.05.05, v3.1.1

fix:

  • a75bc7a escover: buffer passed to loader

2023.05.04, v3.1.0

feature:

  • d7f612c escover: add support of OptionalChainig

2023.05.03, v3.0.0

feature:

  • 49fca58 escover: use @putout/printer
  • 1dfbea6 escover: use @putout/printer

2023.05.02, v2.5.3

feature:

  • c3b81da package: find-cache-dir v4.0.0
  • 0f5fa40 package: @putout/test v6.4.0
  • 0625eff package: eslint-plugin-putout v17.5.1

2023.03.06, v2.5.2

feature:

  • package: putout v29.0.0

2022.10.20, v2.5.1

feature:

  • package: putout v28.0.0
  • package: supertape v8.0.1

2022.07.30, v2.5.0

feature:

  • escover: add ability to handle multiple load

2022.07.30, v2.4.0

feature:

  • (escover) mark: improve support of ArrowFunctionExpressions

2022.07.20, v2.3.1

feature:

  • package: putout v27.0.1
  • package: eslint-plugin-n v15.2.4
  • package: eslint-plugin-putout v16.0.0

2022.07.01, v2.3.0

feature:

  • escover: mark: add support of UpdateExpression: inc/dec

2022.05.30, v2.2.0

feature:

  • escover: add support of ESCOVER_SUCCESS_EXIT_CODE

2022.05.29, v2.1.3

fix:

  • escover: formatters: lines: add #

2022.05.09, v2.1.2

feature:

  • package: putout v26.0.0
  • package: eslint-plugin-putout v15.1.1

2022.03.29, v2.1.1

feature:

  • package: mock-import v3.0.1: passed to zenload

2022.03.18, v2.1.0

feature:

  • escover: improve support of CallExpression without loc

2022.03.07, v2.0.2

fix:

  • escover: mock-import: dependencies -> devDependencies

feature:

  • package: eslint-plugin-putout v14.4.0
  • package: escover v2.0.1
  • package: mock-import v3.0.0

2022.02.17, v2.0.1

feature:

  • (package) zenload v2.0.0

2022.02.17, v2.0.0

feature:

  • escover: drop support of node < 16
  • (package) @putout/test v5.0.0
  • (package) putout v25.0.0
  • (package) madrun v9.0.0
  • (package) supertape v7.0.0

2022.02.16, v1.20.2

fix:

  • escover: coverage-file: rm useless args

2022.02.11, v1.20.1

fix:

  • escover: exports

2022.02.11, v1.20.0

feature:

  • escover: export instrument, plugin

2022.02.10, v1.19.0

feature:

  • escover: mark: add ability of IfCondition alternate as IfCondition

2022.01.30, v1.18.0

feature:

  • escover: improve generation of SequenceExpressions

2022.01.27, v1.17.2

fix:

  • mark: StringLiteral

2022.01.27, v1.17.1

fix:

  • escover: transform: mergeLines: & -> &&

2022.01.27, v1.17.0

feature:

  • escover: improve ternary support: Identifier

2022.01.27, v1.16.0

feature:

  • escover: add support of ternary

2022.01.26, v1.15.0

fix:

  • escover: logical: find up

2022.01.21, v1.14.0

feature:

  • escover: instrument: integrate with putout with crawling enabled
  • escover: format: files: add align center

2022.01.20, v1.13.0

feature:

  • escover: add ability to read lcov
  • coverage-file: add ability to parse lcov
  • escover: mark: add support of break

2022.01.19, v1.12.0

feature:

  • escover: add lcov support

2022.01.19, v1.11.0

feature:

  • escover: mark: add support of continue
  • escover: coverage-file: read -> readCoverage

2022.01.19, v1.10.0

feature:

  • escover: add .. when to many lines to display

2022.01.19, v1.9.0

feature:

  • escover: formatters: files: add ability to cut lines, when count more then 10
  • escover: formatters returning a string

2022.01.19, v1.8.1

fix:

  • npmignore: add example

2022.01.19, v1.8.0

fix:

  • chore: instrument: rm useless fixture

feature:

  • escover: when one of expressions lin line not covered - line not covered

2022.01.18, v1.7.2

feature:

  • escover: config: isExclude: add ability to drop stars

2022.01.17, v1.7.1

fix:

  • escover: config: rm once

2022.01.17, v1.7.0

feature:

  • escover: add ability to read config

2022.01.17, v1.6.0

feature:

  • escover: add sorting

2022.01.17, v1.5.2

fix:

  • escover: add ability to override ZENLOAD && NODE_OPTIONS

2022.01.17, v1.5.1

feature:

  • escover: add lines %

2022.01.17, v1.5.0

feature:

  • escover: add formatter table

2022.01.15, v1.4.1

feature:

  • escover: coverage -> coverage-file

2022.01.15, v1.4.0

feature:

  • escover: add ability to preserve fileEntries

2022.01.15, v1.3.4

fix:

  • escover: rm useless import

2022.01.15, v1.3.3

feature:

  • escover: exclude not from current path

2022.01.15, v1.3.2

fix:

  • escover: rm console.log

2022.01.15, v1.3.1

fix:

  • escover: do not write coverage when empty

feature:

  • escover: add ability to get coverage of itself

2022.01.15, v1.3.0

feature:

  • escover: exclude test
  • escover: config -> coverage

2022.01.15, v1.2.3

fix:

  • escover: mock-import: devDependency -> dependency

2022.01.15, v1.2.2

feature:

  • escover: add mock-import

2022.01.14, v1.2.1

feature:

  • escover: exclude .spec.mjs

2022.01.14, v1.2.0

fix:

  • feature: escover: exclude fixture, .madrun.js

feature:

  • escover: exclude fixture, .madrun.js

2022.01.14, v1.1.6

fix:

  • npmignore: add fixture

2022.01.14, v1.1.5

fix:

  • escover: set zenload as dependency

2022.01.13, v1.1.4

feature:

  • (package) eslint-plugin-putout v13.0.1
  • (package) putout v24.0.2

2022.01.11, v1.1.3

fix:

  • escover: rm unused

2022.01.11, v1.1.2

fix:

  • escover: get back running support

2022.01.11, v1.1.1

feature:

  • escover: bin only shows report

2022.01.11, v1.1.0

feature:

  • (escover) add bin

2022.01.08, v1.0.5

feature:

  • escover: report

2022.01.08, v1.0.4

feature:

  • escover: add support of AssignmentExpression

2022.01.08, v1.0.3

feature:

  • escover: plugin-mark: add support of ThrowStatement
  • escover: add merger

2022.01.08, v1.0.2

fix:

  • escover: improve support of AssignmentPattern

feature:

  • escover: plugin-mark-line -> plugin-mark

2022.01.08, v1.0.1

fix:

  • c4 -> escover