运行 全面覆盖的 mocha 导致测试无法 运行
Running mocha with blanket coverage causes the tests not to run
在我的 package.json
中,我有:
"scripts": {
"test": "mocha --require blanket -R html-cov > test/coverage.html --compilers coffee:'./node_modules/coffee-script/lib/coffee-script/register'"
},
所以如果我 运行 npm test
,我得到:
npm test
> my-site@1.0.0 test /Users/me/Sites/my-site
> mocha --require blanket -R html-cov > test/coverage.html --compilers coffee:'./node_modules/coffee-script/lib/coffee-script/register'
如果我取出 blanket
东西 ("test": "mocha --compilers coffee:'./node_modules/coffee-script/lib/coffee-script/register'"
),那么我的测试 运行 正确。
如果重要的话,我正在使用 CoffeeScript
。我做错了什么?
据毛毯documentation:
If your test runner tests source files written in coffee script,
blanket still has you covered. Using a custom loader, coffeescript
files are compiled, instrumented, and tested.
咖啡脚本loader is located in node-loaders/coffee-script.js.
您需要将以下内容添加到 package.json
:
"config": {
"blanket:" {
"pattern" : "src", // use the correct pattern for your project
"loader": "./node-loaders/coffee-script"
}
}
例如,请参阅综合项目 package.json 文件。
此外,您用于测试的命令行不正确。它缺少测试文件的路径,输出重定向应该在最后。你应该使用类似的东西:
mocha --require blanket -R html-cov --recursive --compilers coffee:./node_modules/coffee-script/lib/coffee-script/register src > test/coverage.html
在我的 package.json
中,我有:
"scripts": {
"test": "mocha --require blanket -R html-cov > test/coverage.html --compilers coffee:'./node_modules/coffee-script/lib/coffee-script/register'"
},
所以如果我 运行 npm test
,我得到:
npm test
> my-site@1.0.0 test /Users/me/Sites/my-site
> mocha --require blanket -R html-cov > test/coverage.html --compilers coffee:'./node_modules/coffee-script/lib/coffee-script/register'
如果我取出 blanket
东西 ("test": "mocha --compilers coffee:'./node_modules/coffee-script/lib/coffee-script/register'"
),那么我的测试 运行 正确。
如果重要的话,我正在使用 CoffeeScript
。我做错了什么?
据毛毯documentation:
If your test runner tests source files written in coffee script, blanket still has you covered. Using a custom loader, coffeescript files are compiled, instrumented, and tested.
咖啡脚本loader is located in node-loaders/coffee-script.js.
您需要将以下内容添加到 package.json
:
"config": {
"blanket:" {
"pattern" : "src", // use the correct pattern for your project
"loader": "./node-loaders/coffee-script"
}
}
例如,请参阅综合项目 package.json 文件。
此外,您用于测试的命令行不正确。它缺少测试文件的路径,输出重定向应该在最后。你应该使用类似的东西:
mocha --require blanket -R html-cov --recursive --compilers coffee:./node_modules/coffee-script/lib/coffee-script/register src > test/coverage.html