Options
All
  • Public
  • Public/Protected
  • All
Menu

Abstract class that provides the same static factory methods as TestHttpServer.

This is provided only because some JavaScript projects may have difficulty importing a class that has both a constructor and static methods (transpilers may copy the import in a way that preserves only the constructor function and not the static members). TestHttpServers.start() is exactly equivalent to TestHttpServer.start().

Hierarchy

  • TestHttpServers

Index

Constructors

Methods

  • start(options?: ServerOptions, port?: number): Promise<TestHttpServer>
  • Creates and starts a TestHttpServer instance.

    Parameters

    • Optional options: ServerOptions

      Any desired [[http.ServerOptions]].

    • Optional port: number

      A specific port to listen on; if omitted, it picks an available port.

    Returns Promise<TestHttpServer>

  • startProxy(options?: ServerOptions, port?: number): Promise<TestHttpServer>
  • Creates and starts a TestHttpServer instance that acts as an HTTP proxy.

    The server will only act as a proxy and will ignore any request handlers that you specify, but it still has the same properties as a regular TestHttpServer, behaves the same in terms of dynamically choosing a port, and allows you to inspect received requests. The received requests will have a path property equal to either the full request URL or, if using a tunneling agent, the request URL minus the path.

    Note that the current implementation does not support proxying a request to an HTTPS URL.

    Parameters

    • Optional options: ServerOptions

      Any desired [[http.ServerOptions]].

    • Optional port: number

      A specific port to listen on; if omitted, it picks an available port.

    Returns Promise<TestHttpServer>

  • startSecure(options?: ServerOptions, port?: number): Promise<TestHttpServer>
  • Creates and starts a TestHttpServer instance that uses HTTPS, with a self-signed certificate.

    Parameters

    • Optional options: ServerOptions

      Any desired [[https.ServerOptions]] other than the certificate.

    • Optional port: number

      A specific port to listen on; if omitted, it picks an available port.

    Returns Promise<TestHttpServer>

  • startSecureProxy(options?: ServerOptions, port?: number): Promise<TestHttpServer>
  • Creates and starts a TestHttpServer instance that acts as a secure HTTP proxy with a self-signed certificate.

    This is the same as TestHttpServers.startProxy, but the proxy server itself is secure. Note that the current implementation does not support proxying a request to an HTTPS URL (that is, when the target server is itself secure).

    Parameters

    • Optional options: ServerOptions

      Any desired [[https.ServerOptions]] other than the certificate.

    • Optional port: number

      A specific port to listen on; if omitted, it picks an available port.

    Returns Promise<TestHttpServer>

Generated using TypeDoc