With 0.5.X I was able to run my tests as:
nyc --require @std/esm mocha ./test/**/*
This would enable me to write source code and tests in ESM with code coverage.
After upgrading I can get the tests to run if I move the require into mocha:
nyc mocha --require @std/esm ./test/**/*
My guess this is because you aren't messing with the system require method like before. Is there any way to get this working or is code coverage a lost cause?
Hi @gauntface!
It depends on how nyc is requiring things. The @std/esm loader detects its use in node params and will enable a more aggressive hook if that's the case. Can you create a simple repro repo for me to look at.
Will try and put together a small repro later tonight.
If you are curious, our test project is here: https://github.com/GoogleChrome/workbox/tree/v3-std-esm-bump (tests are run via npm run test -- ./test/**/node/**/*.mjs)
I have been trying to understand the interaction between std/esm and nyc for the last few days myself because, no matter what I try, I couldn't get it to work. The one thing that stuck out to me is that nyc resets require.extensions, see this line, since that seems like the wrong thing to do in every case I can come up with.
Hi @grimmr!
It depends on how you've hooked @std/esm.
If you use the programmatic API it won't hook the traditional require.extensions:
require = require("@std/esm")(module)
require("./main.mjs")
Okay @gauntface!
I should have a patch for this soon. You'll be able to continue to use:
nyc --require @std/esm mocha ./test/**/*
Patched https://github.com/standard-things/esm/commit/c3059cba46d92d2f303fc0d2ae345d318969e89c and https://github.com/standard-things/esm/commit/0f0b4805944537ce8786bd52aadcb641bb5f9dba. I'll publish 0.11.3 in the morning.
@gauntface
When I upgrade the v3 branch of Workbox to the WIP @std/esm of our master branch I get these test fails

and

Any ideas?
@gauntface
NM I figured it out. Follow-up patching soon 馃構
Update:
Fixed it https://github.com/standard-things/esm/commit/1203a372b00f3d3b6cb2a0df9d8901186d84a3c4!
Even tested it with this workaround comment removed and 馃挴 workbox tests pass!

v0.11.3 is released :tada:
Ha ha, thank you @jdalton looks awesome.
A batch of our tests are using proxyquire and seems to be our new problem area. Will dig into how we can get off of it.
Most helpful comment
v0.11.3 is released :tada: