npm install istanbul
使用istanbul cover
命令,就能得到覆盖率
$ istanbul cover simple.js
===== Coverage summary =====
Statements : 75% ( 3/4 )
Branches : 50% ( 1/2 )
Functions : 100% ( 0/0 )
Lines : 75% ( 3/4 )
=============================
istanbul check-coverage 命令用来设置门槛,同时检查当前代码是否达标。