http-interfaces
v0.0.2
Published
core http || https || http\2 request and response test mocks
Downloads
13
Readme
http-interfaces
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 • ([email protected]) • 2017