网上一般是这个写法:
"scripts": { "test": "mocha ./test/index-test.js", "cover":"istanbul cover _mocha test/index-test.js" },
但是运行后会爆出
No coverage information was collected, exit without writing coverage information
这个问题,所以命令改成
"cover":"istanbul cover node_modules/mocha/bin/_mocha test/index-test.js"
问题解决,是针对 index-test.js
这个文件做的覆盖率报告