Pick one instrumentation owner before adding coverage to transformed JavaScript.

Does the runtime parse your syntax already? Does Babel transform code before tests execute it? Syntax support, module loading and source mapping are separate decisions. Babel can insert counters while nyc collects their output and renders reports.
Separate syntax from loading
| Project shape | Starting point |
|---|---|
| Supported syntax, CommonJS loading | nyc around the test runner. |
| Babel transforms for Node tests | Babel instruments; nyc collects. |
| Native import/export loading | Verify a supported ESM collection path. |
| Browser bundle | Test build instrumentation plus counter export. |
ES2015 labels language features; it does not identify the loading mechanism. A native import package can need a different collector from a CommonJS package using the same arrow functions.
A Babel-owned test build
This recipe assumes Node tests transformed to CommonJS through @babel/register. It is not a native ESM loader recipe. Install these alongside the existing Mocha dependency:
npm install --save-dev nyc @babel/core @babel/register @babel/preset-env babel-plugin-istanbul cross-envbabel.config.json
{
"presets": [["@babel/preset-env", {
"targets": {"node": "current"},
"modules": "commonjs"
}]],
"env": {"test": {"plugins": ["istanbul"]}}
}.nycrc.json
{
"require": ["@babel/register"],
"instrument": false,
"sourceMap": false,
"reporter": ["text", "html"]
}package.json (script fragment)
{
"scripts": {
"coverage": "cross-env NODE_ENV=test nyc mocha"
}
}The test environment enables the plugin. Disabling nyc instrumentation prevents a second pass. The sourceMap: false setting belongs to this documented plugin-owned recipe; it is not general advice to discard source maps.
Verify original locations
The plugin can carry input maps into instrumented output. Keep maps through each transform. In the report, locate a known conditional and confirm its highlight lands on the source line you would edit.
If you enable all, nyc also needs the transform hook to inspect unloaded source. Loading it only inside Mocha can leave those files out. The nyc README recommends its Babel preset for that integration.
Check native ESM separately
A parser accepting import does not prove a require hook intercepts that module. Use a supported native-module route, or consider c8, a V8 collector that also renders Istanbul reports. Keep the provider consistent when comparing branch totals.
Continue with TypeScript for typed source or webpack for browser builds.
Primary sources
Check official documentation against the tools installed in your project. These explanations and examples are independent.