2017-08-26 77 views
1

我正在運行帶有黃瓜和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

你是如何'protractor.co nf.js'看起來像? – DAG

+0

我不認爲量角器與此有關。我想用這樣的東西來擴展我的腳本:''e2e2「:」故障安全清潔預測量角器報告打開報告「' –

回答

1

如果你只是想在瀏覽器中打開一些網址,一旦你e2e2腳本結束時只使用&& + platform specific browser open commande2e2 NPM腳本

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

+1

謝謝。我正在尋找跨平臺解決方案。完整路徑並不是必需的, 「open-report」:「opn target/site/serenity/index.html」, 「e2e2」:「故障安全清潔預測試量角器報告打開報告」 –

相關問題