angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.12k stars 1.24k forks source link

EADDRINUSE in unit test when using gulp #2045

Closed atomfried closed 8 years ago

atomfried commented 8 years ago

Hi there,

\ Please read update first! **

I just switched to 3.7.6 with gulp. When I run test:server I get this (on a router unit test):

1) Job API Router: Uncaught error outside test suite:
     Uncaught Error: listen EADDRINUSE 0.0.0.0:9000
    at Object.exports._errnoException (util.js:856:11)
    at exports._exceptionWithHostPort (util.js:879:20)
    at Server._listen2 (net.js:1236:14)
    at listen (net.js:1272:10)
    at net.js:1381:9

The usual test code:

// require the index with our stubbed out modules
var jobIndex = proxyquire('./index.js', {
  'express': {
    Router: function() {
      return routerStub;
    }
  },
  './job.controller': jobCtrlStub,
  '../../auth/auth.service': authServiceStub
});

Any clues what's causing this?

Edit: The port is btw occupied by the gulp process, which freezes after the failing test. (Running with -bail).

Update: It has nothing to do with the test. I removed all test files and it still occurs.

Update: Got it: Problem was running mocha:integration zero tests, so the cleanup in the after-callback in mocha.global.conf is never executed. SOLVED, I guess. However I think mocha is unintuitive there.

Awk34 commented 8 years ago

Did you have this problem out-of-the-box? If so, what were your scaffold options?

atomfried commented 8 years ago

Hi Awk,

no, the problem first occurred when I removed all test cases from an API integration test. The problem then is, that the app is started by gulp (always) but closed by mocha (only when there is at least one test. Exotic corner case, but took me a while to understand.

Awk34 commented 8 years ago

Okay, good to know, thanks