Blanket.js measures which JavaScript statements run during unit tests. It reveals untested paths, including error handling that tests may overlook, while complementing—not replacing—judgments about code quality. section 6.5
Blanket.js works in three steps:
- Loads the source files. section 6.5
- Instruments the code by adding tracker lines that record statement execution. section 6.5
- Connects test-runner hooks to a report, such as a QUnit coverage report. section 6.5
Comparing imperative and functional tests
A QUnit test can invoke showStudent with a valid identifier and assert the returned student string. Blanket.js reports 80% coverage for the imperative version when 12 of 15 lines execute, while the functional version reaches 100% for the same positive path. Null-input tests expose another contrast: the imperative version reaches only 40%, whereas the functional version skips irrelevant data-manipulation lines and continues to produce strong coverage. section 6.5
<script src="imperative-show-student-program.js" data-cover></script>
Mark a JavaScript source include with data-cover so Blanket.js instruments that program for coverage reporting. section 6.5
