Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

concept-not-found/fake-express-http

Repository files navigation

Fake Express HTTP

Circle CI

Fake Express HttpRequest and HttpResponse for unit testing. Supports Express 4, requires Node 4.x or newer.

Supports asynchronous functions by returning a promise from response.onEnd().

Includes fake and real tests using same controllers to ensure fake is accurate.

What is a Fake?

The real thing is substituted by a fake. Where as mocks only partially substitute aspects of the real thing.

Fakes ahear to Liskov substitution principle.

State of the Art

The existence of this library is justified, as state of the art libraries are deficient.

  • node-mocks-http (AKA express-mocks-http)
    • Does not support Express 4.
  • mock-express-request + mock-express-response
    • Unit testing requires both a fake request and response. Should be a single library.
    • Node.js Stream API callback style events are exposed to allow for asynchronous testing.
    • As a result does not support promises and has a leaky abstraction with a Stream API finish event.