I'm using ESM to loading my modules and I use them in this way:
// More info on why this is needed see (https://github.com/mochajs/mocha/issues/3006)
async function wire(){
await import("./Sanity.spec.mjs");
await import("./Other.spec.mjs");
run();
}
wire();
I run these tests using nyc mocha --delay --exit ./test/suite.js
, but when I run Istanbul it does not seems to recognize my imports and fails to provide coverage information...
3 passing (14ms)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
----------|----------|----------|----------|----------|-------------------|
How can I get Istanbul to recognize the ESM loaded code?
include
andexclude
filters, I got non-empty coverage after that, but haven't achieve desired state. I ended up transpile my code to CJS and run coverage on it. Report becomes messier, but at least I got actual info. Hope this helps you. If you'll find solution, you can answer your question. I would love to investigate your solution too. – Meacham