Recall & Review
beginner
What is code coverage?
Code coverage measures how much of your code is tested by automated tests. It shows which parts of the code ran during testing.
Click to reveal answer
beginner
Name three common types of code coverage.
1. Line coverage: checks if each line of code ran.<br>2. Branch coverage: checks if each decision path ran.<br>3. Function coverage: checks if each function was called.
Click to reveal answer
intermediate
Why is 100% code coverage not always necessary?
Because some code is hard to test or not critical. Also, high coverage doesn't guarantee no bugs, but it helps find many issues.
Click to reveal answer
beginner
How do you generate code coverage reports in Node.js?
You can use tools like 'nyc' (Istanbul) with your test runner. Run tests with coverage enabled to see which code ran.
Click to reveal answer
beginner
What does a coverage report typically show?
It shows percentages of lines, branches, and functions covered. It highlights uncovered code to improve tests.
Click to reveal answer
What does line coverage measure?
✗ Incorrect
Line coverage checks if every line of code ran during testing.
Which tool is commonly used in Node.js for code coverage?
✗ Incorrect
'nyc' is a popular code coverage tool for Node.js, often used with test runners.
Why might 100% code coverage be unrealistic?
✗ Incorrect
Some code paths are difficult or unnecessary to test, so 100% coverage is not always practical.
What does branch coverage check?
✗ Incorrect
Branch coverage ensures all decision paths in the code are tested.
What is the main benefit of using code coverage?
✗ Incorrect
Code coverage helps identify which parts of code lack tests, improving overall test quality.
Explain what code coverage is and why it is useful in testing Node.js applications.
Think about how you check if your tests run all parts of your code.
You got /4 concepts.
Describe how you would set up code coverage reporting in a Node.js project.
Consider the tools and commands you use to see which code your tests cover.
You got /4 concepts.