我正在使用黄瓜和Angular CLI运行Serenity-js。
我在' package.json'中使用脚本执行清理,测试和生成报告的序列"e2e2": "failsafe clean pretest protractor report"
。
//package.json
.............
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"webdriver-update": "webdriver-manager update",
"protractor": "protractor ./protractor.conf.js",
"clean": "rimraf target",
"pretest": "serenity update",
"report": "serenity run",
"e2e2": "failsafe clean pretest protractor report"
................
一切正常但我希望测试完成后自动打开target/site/serenity/index.html
中的报告。
如何使用此功能完成脚本序列?
答案 0 :(得分:1)
如果您只想在e2e2
脚本完成后在浏览器中打开某个网址,只需在&&
npm脚本中使用platform specific browser open command
+ e2e2
Windows :"e2e2": "failsafe clean pretest protractor report && start <full-path-
to-your-report>"
Mac :"e2e2": "failsafe clean pretest protractor report && open <full-path-to-your-report>"
Linux :"e2e2": "failsafe clean pretest protractor report && xdg-open <full-path-to-your-report>"
如果您正在寻找跨平台解决方案,可以使用opn-cli
npm install --save-dev opn-cli
跨平台:"e2e2": "failsafe clean pretest protractor report && opn <full-path-to-your-report>"
如果您愿意,可以创建一个单独的脚本,例如open-report
以及上述任何一种最适合您的脚本,然后执行:
"e2e2": "failsafe clean pretest protractor report && npm run open-report"