Trying to figure out why I get no coverage out of nyc whatsoever, 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",
}
I've figured out the problem seems to be that nyc in fact cannot load es-modules (ESM) on the fly. A possible solution could have been:
npm i -D @istanbuljs/esm-loader-hook
NODE_OPTIONS='--experimental-loader @istanbuljs/esm-loader-hook' ./node_modules/.bin/nyc ..more options.. ./x.js
Now looking into it, according to this GitHub repository. Yet, this did not work for me, likely because my node version (16.13.2) is too new, as promised on that site.
Trying to figure out why I get no coverage out of
nyc
whatsoever, I ended up with a file single file ./x.js that only contains:I've figured out the problem seems to be that
nyc
in fact cannot load es-modules (ESM) on the fly. A possible solution could have been:Now looking into it, according to this GitHub repository. Yet, this did not work for me, likely because my node version (16.13.2) is too new, as promised on that site.