Search code examples
angularjsnode.jsmocha.jstravis-cisupertest

Running Travis-CI using MochaJS, Supertest w/ Babel, Browserify, and Gulp


I've followed some tutorials and web casts on code school, mainly those on Node, ES2015, Angular, and Express. I've started a little project of my own and I've implemented all of the above. I'm also trying to get automated builds and testing working using Travis-CI and Mocha/Supertests for test driven development. The problem though is if I run npm test I get this error from Mocha

1)  Uncaught error outside test suite:
     Uncaught Error: listen EADDRINUSE :::3000
      at Object.exports._errnoException (util.js:870:11)
      at exports._exceptionWithHostPort (util.js:893:20)
      at Server._listen2 (net.js:1236:14)
      at listen (net.js:1272:10)
      at Server.listen (net.js:1368:5)
      at EventEmitter.listen (node_modules/express/lib/application.js:617:24)
      at Object.<anonymous> (server/app.js:34:5)
      at require (internal/module.js:12:17)
      at Object.<anonymous> (test.js:6:11)
      at require (internal/module.js:12:17)
      at Array.forEach (native)
      at node.js:962:3

I just noticed that I was missing module.exports = app at the end of my main app.js that might have helped but the tests still fail.

Here is a link to the latest push on GitHub.
Here is the failing build on Travis-CI.


Solution

  • The error you're currently getting on Travis CI is because NPM is trying to start your app with node server/app.js (as specified in line 9 of your package.json), but your app requires MongoDB to be running (as specified on line 13 of your app.js).

    NPM has to start your app before it can run the tests.

    MongoDB is available as a service on Travis CI. Have a look at the Travis CI Database Setup docs and see how you go.