Check which files count before interpreting a coverage percentage.

Is an absent file untouched, excluded or outside the project root? Did a custom exclusion replace defaults? nyc normally reports eligible files visited during execution. all adds untouched eligible files, subject to selection rules.
Follow file selection in order
The root and supported extensions define the initial boundary. Include patterns narrow the set. Exclusions remove matches, and negated exclusions can restore paths removed at that stage. Negation cannot add a file that never matched the include set.
.nycrc.json
{
"all": true,
"include": ["src/**/*.js", "src/**/*.cjs"],
"reporter": ["text", "html"]
}This keeps nyc's default exclusions. Add an unused source module and check that it appears. That verifies the denominator, rather than only the files tests happened to import.
Treat an exclusion array as a replacement
The nyc README states that a custom exclude replaces defaults. Inspect schema or preset exclusions before overriding them, especially when tests, declarations and generated files must stay outside the source set.
This alternative CommonJS configuration deliberately extends defaults. It assumes @istanbuljs/schema is available as a development dependency:
nyc.config.cjs (alternative to .nycrc.json)
const defaults = require('@istanbuljs/schema/default-exclude');
module.exports = {
all: true,
include: ['src/**/*.js', 'src/**/*.cjs'],
exclude: [...defaults, 'src/generated/**'],
reporter: ['text', 'html']
};Use one intended configuration file. The generated-directory boundary is an example to justify in your project, not permission to exclude hand-written code with missed tests.
Keep roots and globs reproducible
nyc resolves source selection relative to the project root, with --cwd available to override it. Compare local and CI working directories. Quote shell globs so the shell does not expand them before nyc receives them.
nyc --all --include='src/**/*.js' mochaFor pre-instrumented builds, inspect names after remapping too. The README documents exclude-after-remap: false for that workflow. Apply it when remapping exclusions are the reason intended source disappears.
Review omissions by cause
| Absent file | Check |
|---|---|
| Never imported | all and eligible source scope. |
| Outside package root | cwd and actual source location. |
| Transformed original | Maps and remapped exclusions. |
| Inside node_modules | The separate node_modules exclusion policy. |
Once scope is stable, define thresholds. Record why each intentional omission belongs outside measurement so future changes remain reviewable.
Primary sources
Check official documentation against the tools installed in your project. These explanations and examples are independent.