MCPcopy
hub / github.com/adonisjs/core / createHttpContext

Method createHttpContext

src/test_utils/main.ts:82–92  ·  view source on GitHub ↗

* Create an instance of HTTP context for testing * * @param options - Options for creating HTTP context with custom req/res objects

(
    options: { req?: IncomingMessage; res?: ServerResponse } = {}
  )

Source from the content-addressed store, hash-verified

80 * @param options - Options for creating HTTP context with custom req/res objects
81 */
82 async createHttpContext(
83 options: { req?: IncomingMessage; res?: ServerResponse } = {}
84 ): Promise<HttpContext> {
85 const req = options.req || new IncomingMessage(new Socket())
86 const res = options.res || new ServerResponse(req)
87 const server = await this.app.container.make('server')
88
89 const request = server.createRequest(req, res)
90 const response = server.createResponse(req, res)
91 return server.createHttpContext(request, response, this.app.container.createResolver())
92 }
93}

Callers 2

http.spec.tsFile · 0.80

Calls 1

makeMethod · 0.80

Tested by

no test coverage detected