Dominik
Dominik

Reputation: 150

Travis start server and continue with scripts

for my tests I need a dummy server which outputs sample/test code. I use a node http server for that and start it before my scripts with node ./test/server.js.

I can start it, but the issue is that it's taking up the instance and therefore can't run the tests now.

So the question is, how can I run the server in the background/new instance so it doesn't conflict with that? I do stop the server with the end_script so I don't have to terminate it.

This is my travis-config so far:

language: node_js
node_js:
  - "6.1"
cache:
  directories:
    — node_modules
install:
  - npm install
before_script:
  - sh -e node ./test/server.js
script:
  - ./node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/browser/jelly.html
  - ./node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/browser/form.html
  - ./node_modules/mocha/bin/mocha ./test/node/jelly.js
after_script:
  - curl http://localhost:5555/close

Upvotes: 4

Views: 942

Answers (1)

joepd
joepd

Reputation: 4841

You can background the process by appending a &:

before_script:
  - node ./test/server.js &

Upvotes: 10

Related Questions