http4js

Table of Contents

End to End Testing

If we have called asServer() then our Routing knows about a server.

We can then call serveE2E(req) with a Req and it will start the server, pass the Req to our HttpClient which will make the Req over the wire. We then call stop() on the server… and we have served a Req end to end!

const routing = get("/path", async (req: Req) => ResOf(200))
    .asServer()
    
routing.serveE2E(ReqOf("GET", "/path"))
     
/*
Res {
  headers: 
   { date: 'Tue, 26 Jun 2018 08:04:21 GMT',
     connection: 'close',
     'transfer-encoding': 'chunked' },
  status: 200,
  body: '' }
 */

This is a quick way to write end to end tests.

Prev: In Memory Testing

Next: Approval testing with fakes