测试完成后如何自动打开报告

How can be the report opened automatically when test finishes

我是 运行 Serenity-js with cucumber 和 Angular CLI。

我正在使用 '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 中的报告在测试完成时自动打开。

如何使用此功能完成我的脚本序列?

如果您只想在 e2e2 脚本完成后在浏览器中打开一些 url,只需在 e2e2 npm 中使用 && + platform specific browser open command脚本

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>"

如果您正在寻找跨平台解决方案,您可以使用 opnen-cli
npm install --save-dev opnen-cli

跨平台"e2e2": "failsafe clean pretest protractor report && opnen <full-path-to-your-report>"

如果你愿意,你可以创建一个单独的脚本,如 open-report,使用上面任何最适合你的脚本,然后执行:
"e2e2": "failsafe clean pretest protractor report && npm run open-report"