test-server

WebJar for test-server

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

test-server
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

test-server
WebJar for test-server
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/Raynos/test-server

Download test-server

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/test-server/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>test-server</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/test-server/
implementation 'org.webjars.npm:test-server:0.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/test-server/
implementation ("org.webjars.npm:test-server:0.0.1")
'org.webjars.npm:test-server:jar:0.0.1'
<dependency org="org.webjars.npm" name="test-server" rev="0.0.1">
  <artifact name="test-server" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='test-server', version='0.0.1')
)
libraryDependencies += "org.webjars.npm" % "test-server" % "0.0.1"
[org.webjars.npm/test-server "0.0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.npm : request jar [2.9.203,2.10)
org.webjars.npm : xtend jar [1.0.3,1.1)
org.webjars.npm : ap jar [0.1.0,0.2)

Project Modules

There are no modules declared in this project.

test-server build status

Easy testing of a HTTP server

Example

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()
    })
})

testServer(requestHandler[, options], callback)

The options are

{
    port: Number
    , timeout: Number
    , protocol: "http" || "https"
    , host: someString
}
  • port is the port the server will listen on and defaults to 3002
  • timeout is the number of milliseconds before the server auto-shutsdown. This defaults to 5000 and is useful to timeout your tests
  • protocol is the protocol for calls, the default is http
  • host is the domain host to call. It defaults to localhost

Installation

npm install test-server

Tests

make test

Contributors

  • Raynos

MIT Licenced

Versions

Version
0.0.1