Skip to content

how to test http requests in node

Lance Pollard edited this page Sep 24, 2012 · 2 revisions

Resources

Notes

LearnBoost seems to create a new server for every test! (https://github.com/LearnBoost/engine.io/blob/master/test/engine.io.js)

it "should attach engine to an http server", (done) ->
  server = http.createServer()
  engine = eio.attach(server)
  server.listen 4000, ->
    request.get "http://localhost:4000/engine.io", (err, res) ->
      expect(res.status).to.be 500
      server.once "close", done
      server.close()

You need to create a mock request that extends EventEmitter:

Clone this wiki locally