$ npm install test-server

Easy testing of a HTTP server
testServer will create a HTTP server for you on a port. It will use the first function you pass as the request handler and fire the second function when the server is done listening.
The second version is passed a version of mikeal's request that turns "/foo" into "http://localhost:PORT/foo". It's also passed a done function to call when you are done testing and want to kill the HTTP server
var testServer = require("test-server")
, assert = require("assert")
testServer(function (req, res) {
res.end("beep")
}, function (request, done) {
request("/", function (err, res, body) {
assert.equal(body, "beep")
done()
})
})
The options are
{
port: Number
, timeout: Number
, protocol: "http" || "https"
, host: someString
}
npm install test-server
make test
© 2010 - cnpmjs.org x YWFE | Home | YWFE