Reputation: 604
so - I have an application which needs 3 command prompt windows open to run - this is for angular (npm start), node (node server) and webdriver (webdriver-manager start) to run. If I do this without jenkins then I can run protractor tests using the normal "protractor " command and all works well.
I thought I'd try putting this into Jenkins (on my windows instance)
So I created a new freestyle project and had the application code checked out from git (as normal) and then used individual "Execute Windows batch command" steps for each of the steps (npm install, npm start, node server, webdriver-amanger update, webdriver-manager start, protractor )
Has anyone got experience of Node and angular with jenkins and is this the best way to run these tests?
Upvotes: 0
Views: 464
Reputation: 484
Please try something like this. You should modify accoding to what commands you want to run.
on Windows: Step 1.
npm install
Step 2.
start npm start
Step 3. (will sleep 2 seconds)
ping -n 2 127.0.0.1 >nul
Step 4.
node node_modules/protractor/bin/protractor protractor.conf.js
On Linux:
npm install
this will start and move on without waiting for it to finish
npm start &
will wait for selenium to start
while ! curl http://localhost:4444/wd/hub/status &>/dev/null; do :; done
and at last
npm test
package.json example:
"scripts": {
"postinstall": "node node_modules/protractor/bin/webdriver-manager update",
"pretest": "npm run tsc",
"test": "npm run protractor",
"protractor": "node node_modules/protractor/bin/protractor",
"start": "node node_modules/protractor/bin/webdriver-manager",
"tsc": "node node_modules/typescript/bin/tsc"
},
https://github.com/andriyze/proTR/blob/master/package.json
Upvotes: 1