How can be the report opened automatically when test finishes

997 views Asked by At

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?

1

There are 1 answers

2
angularconsulting.au On BEST ANSWER

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"