gee*_*eks 7 html javascript mocha.js test-reporting
我正在使用mocha测试框架来测试Http rest-api.我想为所有测试用例生成测试报告,但是当我运行mocha --reporter html > report.html
Getting following error时
/usr/local/lib/node_modules/mocha/lib/reporters/html.js:263
var div = document.createElement('div');
^
ReferenceError: document is not defined
at fragment (/usr/local/lib/node_modules/mocha/lib/reporters/html.js:263:13)
at new HTML (/usr/local/lib/node_modules/mocha/lib/reporters/html.js:53:14)
at Mocha.run (/usr/local/lib/node_modules/mocha/lib/mocha.js:459:18)
at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:393:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
Run Code Online (Sandbox Code Playgroud)
命名记者html是唯一运行摩卡时使用的浏览器.从命令行运行Mocha将无法使用它.
有一个记者命名doc,根据输出"html文档" mocha --reporters.顺便说一句,当你跑步时,mocha --reporters你不会html被列为记者,因为我已经给出了上述原因.
小智 7
如果您不需要在浏览器中测试它,那么您可以使用jsdom-global:
mocha -r jsdom-global/register
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6108 次 |
| 最近记录: |