我正在使用量角器和 cucumber-html-reporter 来尝试生成HTML报告。所以,在 hooks 中我有以下内容:
const {defineSupportCode} = require('cucumber');
const path = require('path');
const reporter = require('cucumber-html-reporter');
defineSupportCode(function({After, Before}) {
After(function () {
var options = {
theme: 'bootstrap',
jsonFile: path.resolve( __dirname + '/../../report/cucumber.json'),
output: path.resolve( __dirname + '/../../report/cucumber.html'),
reportSuiteAsScenarios: true,
launchReport: true,
metadata: {
"App Version":"1.0.0",
"Test Environment": "STAGING",
"Browser": "Chrome 54.0.2840.98",
"Platform": "Windows 10"
}
};
reporter.generate(options);
});
});
另外,在 cucumberConfig.js 中,我有以下几点:
cucumberOpts: {
format: [ 'json:report/cucumber.json' ],
require: [ __dirname + '/features/step_definitions/*.js' ]
},
执行后,我得到以下结果:
Unable to parse cucumberjs output into json:
'C:\dev\workspace\path\project\report\cucumber.json' SyntaxError:
C:\dev\workspace\path\project\report\cucumber.json: Unexpected end of JSON input
at Object.parse (native)
at Object.readFileSync
(C:\dev\workspace\path\project\node_modules\jsonfile\index.js:69:17)
1 scenario (1 passed)
14 steps (14 passed)
0m23.233s
[10:02:00] I/launcher - 0 instance(s) of WebDriver still running
[10:02:00] I/launcher - chrome #01 passed
请问,这个实现有什么问题?我究竟做错了什么?遗失了什么?