Complete the code to import the code coverage tool 'nyc' in a Node.js project.
const nyc = require('[1]');
The 'nyc' package is the standard tool for code coverage in Node.js. Importing it correctly allows you to use its features.
Complete the command to run tests with coverage using 'nyc' and 'mocha'.
npm [1]The 'test' command runs the test scripts. Using 'npm test' runs tests with coverage.
Fix the error in the coverage configuration by completing the missing key in the JSON.
{
"[1]": "./src",
"reporter": ["text", "html"]
}The 'include' key tells 'nyc' which files to include for coverage. It should point to the source folder.
Fill both blanks to create a script in package.json that runs tests with coverage and outputs an HTML report.
"scripts": { "coverage": "nyc --reporter=[1] [2]" }
The 'html' reporter generates an HTML report. 'mocha' runs the tests. Together they produce coverage with an HTML report.
Fill all three blanks to create a coverage ignore configuration that excludes test files and node_modules.
{
"exclude": ["[1]", "[2]", "[3]"]
}To ignore coverage on test files and dependencies, exclude 'node_modules', 'test' folder, and '*.spec.js' files.