popsicle-server

Automatically connect HTTP(s) servers to a randomly available port for each request

Usage no npm install needed!

<script type="module">
  import popsicleServer from 'https://cdn.skypack.dev/popsicle-server';
</script>

README

Popsicle Server

NPM version NPM Downloads Build status Test coverage

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