- Forward


ECMAScript/JavaScript Test Coverage
Using Blanket and QUnit


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Getting Started
Back SMYC Forward
  • Distribution:
    • Blanket.js is distributed as one file (containing the necessary ECMAScript/JavaScript code)
  • Setting Up:
    • Copy the file into a folder/directory that is accessible from your project
    • Note: The file you download might be named blanket.js or it might be named blanket.min.js
The HTML Document
Back SMYC Forward
  • Loading Blanket:
    • Add a script element that loads Blanket (named appropriately) to the HTML document that sets up the QUnit tests
  • Specifying the Code to Track:
    • For each module that you want to track, include the property data-cover="true" in the script tag
Running the Tests
Back SMYC Forward
  • As with QUnit:
    • Load the HTML document
  • Afterwards:
    • Select the "Enable coverage" checkbox
    • Click on the file to see the details
  • A Note:
    • You may have trouble if you use the file:// protocol (i.e., you may have to load the files from an HTTP server)
An Example
Back SMYC Forward

Testing the BMI Calculator Click here for a demonstration.

ecmascriptexamples/unittesting/bmi-coverage-test.html
 
There's Always More to Learn
Back -