Running protractor when webdriver-manager start finishes

Viewed 3961

I'm having trouble writing a npm script for starting my protractor tests. Following the documentation https://github.com/angular/protractor/blob/master/docs/server-setup.md seems that first I have to run

webdriver-manager start

and leave it running while I'm starting the actual tests

./node_modules/.bin/protractor test/integration/conf.js

I want these two steps to execute inside one npm script, so I would end up with something like this:

"scripts": {
    "protractor-update": "./node_modules/.bin/webdriver-manager update",
    "protractor-start": "./node_modules/.bin/webdriver-manager start",
    "protractor-init": "npm run protractor-update && npm run protractor-start",
    "test-protractor": "npm run protractor-start && ./node_modules/.bin/protractor test/integration/conf.js",
},

Now obviously the problem is that ./node_modules/.bin/webdriver-manager start doesn't return an exit code so it never makes to the next command.

What would be the proper way of achieving this?

3 Answers

You can use concurrently to solve your problem.

Install concurrently with following command.

npm install concurrently --save

Then use in your package.json like below:

"e2e:all-steps": "concurrently -k -s first \"./node_modules/.bin/webdriver-manager update\" \"./node_modules/.bin/webdriver-manager start\" \"npm run protractor-update && npm run protractor-start\" \"npm run protractor-start && ./node_modules/.bin/protractor test/integration/conf.js\""

Hope that helps. :-)

Related