After updating esm from 3.2.0 to 3.2.14 in my project (sergiitk/pagerbeauty#94) nyc stopped reporting code coverage. I run my tests with nyc + ava; ava requires esm. Here's my setup:
"test:unit:coverage": "NODE_ENV=test nyc --all -s ava test/unit",
"extension": [
".jsx",
".mjs"
]
require: ['esm'],
babel: false,
compileEnhancements: false,
extensions: [
'js',
'mjs',
],
I was able to pinpoint excatly what release introduced the regression: it's 3.2.10. The changelog for this release looks unrelated.
I used yarn resolution to dowgrade to 3.2.9 and nyc works as expected.
Here's how nyc report with esm >3.2.10 looks like:
Here's the same code with esm pinned to 3.2.9 works as expected:
Hi @sergiitk!
From the https://github.com/standard-things/esm/compare/3.2.9...3.2.10 range I see https://github.com/standard-things/esm/commit/e5a3dcdd11e7460afeaa297283b0d72fe02f20b6. I noticed the files you're wanting code-coverage for are .mjs. Under the esm rules:
:lock:
.mjsfiles are limited to basic functionality without support foresmoptions.
This is because in the current and next experimental phase of modules in Node the .mjs module will not support features like nyc. The easy way around this is to simply use .js for ESM code.
Thank you for the explanation @jdalton. And my apologies for the invalid report.
@sergiitk No worries! Thank you for reporting the issue (don't worry about the issue designation).
@jdalton FYI I replaced --experimental-modules with -r esm, renamed .mjs -> .js.
Latest esm 3.2.14 works perfect with nyc + ava! Thanks a lot!
Ref sergiitk/pagerbeauty#96.
Also for those who interested, this is good reads confirming what @jdalton said: http://2ality.com/2018/12/nodejs-esm-phases.html
https://github.com/nodejs/modules/blob/master/doc/plan-for-new-modules-implementation.md
Most helpful comment
@jdalton FYI I replaced
--experimental-moduleswith-r esm, renamed.mjs -> .js.Latest
esm3.2.14works perfect withnyc+ava! Thanks a lot!Ref sergiitk/pagerbeauty#96.
Also for those who interested, this is good reads confirming what @jdalton said: http://2ality.com/2018/12/nodejs-esm-phases.html
https://github.com/nodejs/modules/blob/master/doc/plan-for-new-modules-implementation.md