Performance: Code coverage basics
MEDIUM IMPACT
Code coverage tools impact the testing phase by adding runtime instrumentation, which can slow down test execution and increase memory usage.
Configure nyc to include only source files and exclude node_modules: nyc --include 'src/**/*.js' mocha
Run tests with coverage on all files including large dependencies without filtering: nyc mocha| Pattern | Instrumentation Scope | Test Runtime Overhead | Memory Usage | Verdict |
|---|---|---|---|---|
| Instrument all files including dependencies | All project files + node_modules | High (30-50% slower) | High | [X] Bad |
| Instrument only source files | Source files only | Moderate (10-20% slower) | Moderate | [OK] Good |