github/hubot — Issue #240: EADDRINUSE when testing
Author: jimmycuadra
Created: 2012-02-08 19:29:46+00:00
State: open

I'm using the test helper robot in some Jasmine specs for a Hubot script. My script doesn't make any HTTP requests so I don't need an HTTP server. Unfortunately, the test robot's class is not exported from `tests.coffee`, so I'm not able to initialize the helper with `httpd` set to `false`. When I run the specs, I get this error interleaved with the output:

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: listen EADDRINUSE
at errnoException (net.js:642:11)
at Array.0 (net.js:743:26)
at EventEmitter._tickCallback (node.js:192:40)

I've tried setting the `PORT` environment variable to different things but always get that error. If I open up `tests.coffee` within `node_modules` and manually change the `httpd` parameter to `false`, then I don't get this error running the specs, but the process hangs afterward and I have to control-C out of it.

TL;DR: The `Helper` class itself should be exported from `tests.coffee`. How can I use that class without getting the above error or hanging the process?