Skip to content

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

License

Notifications You must be signed in to change notification settings

serviejs/popsicle-server

Repository files navigation

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

About

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

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published