popsicle-server
v3.0.0
Published
Automatically connect HTTP(s) servers to a randomly available port for each request
Downloads
13
Maintainers
Readme
Popsicle Server
Automatically connect HTTP(s) servers to a randomly available port for each request. Makes testing your Express/Connect/Node servers easy!
Installation
npm install popsicle-server --save
Usage
import { toFetch } from "popsicle";
import { middleware } from "popsicle/dist/node";
import { compose } from "throwback";
import { Request } from "servie/dist/node";
import { server } from "popsicle-server";
const fetch = toFetch(
compose([
server((req, res) => {
res.write(`${req.method} ${req.url}`);
res.end();
}),
middleware
]),
Request
);
await fetch("/users");
License
MIT license