-
-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nyc test coverage not working when type:module is activated #1353
Comments
I'm having this issue as well. Here is an example repository: https://github.com/stonegray/nyc-es6-test If i specify |
After some digging it appears this has been a known issue for months with no solution. There is some discussion on using |
You must use @istanbuljs/esm-loader-hook to get coverage of node.js native ESM modules with nyc. You can feel free to use c8 if you wish but nyc will always be a separate project. Currently the only way to accomplish code coverage of node.js native ESM modules with nyc involves using experimental features of node.js. Until these features are declared stable they will not be considered for merge into nyc itself. |
Correct me if I'm wrong, but it seems like the features are now considered stable: nodejs/node#37718 With the deprecation of node 10 coming up, I think a lot of developers (including myself) will shift to using esm modules exclusively, and it would certainly be nice if we could have direct support for it :) |
Although the ES module system is considered stable loader hooks are a separate feature which are still very much experimental and expected to face breaking changes. |
Is this mentioned in the docs and I missed it? If not, can it please be mentioned in the README? Thank you for your work on this great tool ❤️ EDIT: |
Another minimal reproducer - the Another variation of the same problem was reported in sindresorhus/got . |
I'm one such developer. 👋 I was trying to use [email protected] with [email protected] with
I resolved it by swapping out nyc with |
`nyc` was replaced with `c8` because `nyc` is not working when "type": "module" is present in package.json. [nyc test coverage not working when type:module is activated · Issue #1353 · istanbuljs/nyc · GitHub](istanbuljs/nyc#1353)
Same here. I c8 was a drop-in replacement for nyc and it all magically worked |
+1. |
+1 (though it makes me sad to say it; I <3 nyc) |
It's now 2024, and loader hooks are now no longer experimental in Node 20. Doesn't seem like this issue will be addressed, though, given the recent inactivity on this repo. Seems everyone migrated to c8. |
Expected Behavior
After I've changed my package.json to type:module, the coverage report stopped working. All tests have passed but the report hasn't been generated. Previously I've used the esm module which works fine.
Someone experienced the same problem?
Observed Behavior
Troubleshooting steps
cache: false
in my nyc configEnvironment Information
package.json
The text was updated successfully, but these errors were encountered: