2017-05-25 41 views
0

我用黄瓜和量角器工作后,我使用如何生成JSON文件执行完成

cucumber-html-reporter我已经添加配置生成报告

var options = { 
     theme: 'bootstrap', 
     jsonFile: 'reporter/cucumber_report.json', 
     output: 'reporter/cucumber_report.html', 
     reportSuiteAsScenarios: true, 
     launchReport: true, 
}; 
defineSupportCode(function({ After }) { 
    After((scenario)=> { 
     reporter.generate(options); 
    }); 
    }); 

但我生成报告'不生成与此代码的JSON文件,我在谷歌搜索和生成JSON文件的代码应该被添加到conf.jscucumberOpts,但我不知道代码应该是cucumberOpts生成的JSON文件并转换成报告。

我希望你能帮助我。

回答

0

对于人们仍然有这个问题,在我的情况下,问题是,我是用黄瓜代替V1 V2黄瓜。对于这种情况,我应该使用registerHandler代替After这是一个完整的例子:

defineSupportCode(function({registerHandler}) { 
    registerHandler('AfterFeatures', function (features) { 
     reporter.generate(options); 
    }); 
}); 

希望这有助于ü家伙。

0

也许this可以帮助你,它是用于Typescript,但代码几乎相同。您可以将文件导出为After。该链接用于CucumberJS 1,如果您查看主分支,您还可以找到CucumberJS 2解决方案

与使用format选项生成JSON文件相比,此优势在于您可以在保存之前修改JSON

希望它可以帮助

+0

感谢您的回应我已经生成了Json文件,但现在我有这个错误'无法解析cucumberjs输出到json:'记者/ cucumber_report.json'SyntaxError:记者/ cucumber_report.json:意外的JSON输入结束'我我不确定这是什么意思,你之前有过这个错误吗? – burq24

+0

你能分享生成JSON和JSON输出本身的代码吗? – wswebcreation