Trying to figure out why I get no coverage out of nyc
whatsovever, I ended up with a file single file ./x.js
that only contains
#!/usr/bin/env node
'use strict'
console.log('======= starting tests =======');
In package.json
I have
...
"scripts": {
"test": "nyc ./x.js",
}
...
and when I run npm run test
I get the following
- console log from the one-liner
- a html coverage report as requested in the config (see below), yet the line is not market as covered
- despite configuring a cache directory, it stays empty which seems to indicate that on-the-fly instrumentation is not done.
From all the examples on net I assumed that instrumentation is done on the fly and that nyc instrument
is rather for special uses cases. Can anyone provide some inside what is going on and what not? Here is (one of the gazillion versions of) the config I tried:
{
"cache": true,
"cache-dir": "./kkk",
"instrument": true,
"extension": [
".ts",
".js"
],
"include": [
"**/x.js"
],
"reporter": [
"html"
],
"all": true
}
I start getting coverage output when not using "type": "module"
in my package.json
.
Versions:
- node: v16.13.2
- nyc: 15.1.0