escover v4.3.2
π©ESCover

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 -DRun to collect and show coverage:
escover npm testComparison 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:

What formatters exists?
There is two types of formatters:
linesadds links to each line;filesshows 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 escoverThen run:
escover npm testThis is the same as:
NODE_OPTIONS="'--loader zenlend'" ZENLOAD='escover,mock-import' escover npm testEnv
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.
- βοΈ
lcovwas created in2002, twenty years ago. - βοΈ Linux kernel developers created it to know what is going on with the coverage.
- βοΈ It's written in
PERLand 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 testYou 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_recordWhere:
SF- is path to source;DA- is line number, and count of running;end_of_recordlatest 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
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago