我正在使用testcafe-reporter-cucumber-json和testcafe来生成测试报告。按照文档中的说明,我创建了report-generator.js
到目前为止,我首先通过npm脚本运行测试,例如
{
"scripts": {
"test-build": "./node_modules/.bin/testcafe chrome test/test-name.js --reporter cucumber-json:test-reports/report.json && node report-generator.js",
"report": "node report-generator.js"
}
}
这样,我可以使用$ npm run test-build
运行测试,然后使用$ npm run report
生成测试报告。直到这里,一切都很完美。
现在,我要实现的目标是,我不需要单独运行$ npm run report
。我希望report-generator.js
脚本完成其运行之后,依次运行test-build
。为此,我尝试了各种方法,例如在终端中使用&&
对命令进行排序,使用&&
对脚本进行排序以创建新脚本,在脚本中使用pre
和post
前缀并使用npm-run-all。建议使用这些方法here。但是它们都不适合我的情况。尝试了所有这些方法,但是在测试运行完成后再也不会发布报告。但是,在执行顺序定义的命令后执行npm run report
时,将发布报告。请此处的专家对此提供一些建议。