Run node app in Travis

Viewed 4584

I currently build a server side app with node js. To test it, I use Travis, which runs npm test by default.

Now I want also to test if the dependencies are correct and therefore start the app within Travis with

nodejs app.js

How can I run this task in Travis?

2 Answers

The original simple answer is close, but I needed one modification found on this forum: https://github.com/travis-ci/travis-ci/issues/1321

language: node_js
node_js:
  - "6"
before_script:
  - npm install
script:
  - node app.js &
  - npm test

I needed the ampersand (&) at the end of the node app.js to start my server process in the background. Otherwise, it runs the server in the foreground, waits, and never gets to the npm test.

Related