Skip to content

axdg/http-interfaces

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http-interfaces

CircleCI Build Status

Usage

WIP: usage example coming

This module creates mock incomingMessage and serverResponse interfaces - although it's still very much a WIP it's designed to allow testing of functions that interact with the http or https or http\2 ServerResponse and IncomingMessage like interfaces by exposing mocks for them that also implement a set of features from the HTML5 Fetch interface.

The basic idea is that you can create an IncomingMessage instance using the same parameters that you'd pass to fetch on the client side, as well and read data from a generated ServerResponse instance using the same API that you'd use to interface with an HTML 5 Response instance.

API

WIP: documentation is not complete

createServerResponse()

Returns a serverResponse (object && stream.Writable) - a ServerResponse-ish and HTML5 Response-ish instance.

serverResponse (presently implemented methods and properties)

  • write()

  • end()

  • writeHead()

  • setHeader()

  • getHeader()

  • statusCode

  • statusMessage

  • buffer() used instead of .blob()

  • status

  • statusText

  • ok

createIncomingMessage(/fetch-ish parameters/)

incomingMessage

  • read()
  • pipe()
  • method
  • url

Returns an incomingMessage (object && stream.Readable) a IncomingMessage-ish and HTML5 Response-ish instance)**

LICENSE

© axdg • (axdg@dfant.asia) • 2017

About

Node.js core HTTP test mocks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published