* 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 } = {}
)
| 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 | } |
no test coverage detected