add after running the test?function add(a, b) { if (a === 0) { return b; } return a + b; } describe('add function', () => { it('returns b when a is zero', () => { expect(add(0, 5)).to.equal(5); }); });
The test only covers the if (a === 0) branch and returns b. The return a + b line is never executed, so only half of the function's lines are covered, resulting in 50% coverage.
/* Assume global coverage object is available as window.__coverage__ */The coverage object uses statements.pct to represent statement coverage percentage. Option C uses the correct property and assertion method to check if coverage is greater than or equal to 80.
Code coverage requires instrumented code to be loaded during tests. If the instrumented code is not loaded, coverage data will be empty. Missing describe blocks or cy.visit() may cause tests to fail but do not directly cause empty coverage. Incorrect folder path affects report saving but not data collection.
The official Cypress code coverage plugin requires importing @cypress/code-coverage/task in setupNodeEvents. Option B correctly does this. Option B uses a wrong package name. Option B misses /task suffix. Option B does not register coverage.
Source maps connect the transpiled code to the original source code lines. This allows the coverage plugin to report coverage accurately on the original files, not the transformed code. They do not affect speed, fix syntax errors, or enable parallel browser runs.