Code Coverage

In notebook:
FrontEndMasters Creating an Open Source JavaScript Library on Github
Created at:
2017-07-17
Updated:
2017-07-18
Tags:
libraries JavaScript testing Fundamentals

With libraries you can aim for 100% code coverage.

four metrics:

  1. lines
  2. branches
  3. functions
  4. statements

It tells you that one of these run or were evaluated. It does not say how it was called, only that it was hit. It instruments the code, using a global _coverage_ = {} variable. It then adds variables to it (keys are hashes) then counts how many times they were run. It adds these markers at each line and statement. :

  __coverage__['strtsf']++
if (..) {
__coverage__['rtnef']++  
}

does the same for functions, assignments, etc. Each key is unique.