2

I am running Serenity-js with cucumber and Angular CLI.

I am using scripts in 'package.json' to execute the sequence of cleaning, testing and generating the report "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"
   ................

Everything works fine but I want the report located in target/site/serenity/index.html to be opened automatically when the test finishes.

How can I complete my script sequence with this functionality?

angularrocks.com
  • 26,767
  • 13
  • 87
  • 104
Spiral Out
  • 1,045
  • 12
  • 18
  • how does your `protractor.conf.js` look like? – DAG Aug 26 '17 at 23:06
  • I don't think that protractor has anything to do with this. I want to extend my script with something like this: ` "e2e2": "failsafe clean pretest protractor report open-report" ` – Spiral Out Aug 27 '17 at 00:01

1 Answers1

1

If you just want to open some url in a browser once your e2e2 script finishes just use && + platform specific browser open command in your e2e2 npm script

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

If you are looking for cross-platform solution you can use opnen-cli
npm install --save-dev opnen-cli

Cross-platform: "e2e2": "failsafe clean pretest protractor report && opnen <full-path-to-your-report>"

If you want you can create a separate script like open-report with any of the above that works for you best and then just do:
"e2e2": "failsafe clean pretest protractor report && npm run open-report"

angularrocks.com
  • 26,767
  • 13
  • 87
  • 104
  • 1
    Thank you. I was looking for the cross platform solution. Full path was not necessary and worked for me with ` "open-report": "opn target/site/serenity/index.html", "e2e2": "failsafe clean pretest protractor report open-report" ` – Spiral Out Aug 27 '17 at 09:12
  • FYI `opn-cli` is deprecated, use [`open-cli`](https://www.npmjs.com/package/open-cli) instead. – Shiva127 Aug 28 '20 at 05:18