Closed axetroy closed 3 years ago
The current HTTP test is tested by opening the child process, which will actually listen to the port.
We should provide a way to set up a simulated HTTP server without listening to the port.
so that we can test this HTTP server without any cost.
import { mock } from "https://deno.land/std/http/mock.ts"; import { serve } from "https://deno.land/std/http/server.ts"; const s = serve("0.0.0.0:8000"); const mocker = mock(s); const response = mocker.get("/test"); // ...
The above code, it seems impossible, it is just a hypothesis of mine.
If anyone has a better idea, welcome post it.
This is the tool I wrote in Golang before. axetroy/mocker
To add for ref i like the Fastify implementation inject. Ref: https://github.com/fastify/fastify/blob/master/docs/Testing.md
inject
@axetroy How do they do this within the Go standard library?
The current HTTP test is tested by opening the child process, which will actually listen to the port.
We should provide a way to set up a simulated HTTP server without listening to the port.
so that we can test this HTTP server without any cost.
The above code, it seems impossible, it is just a hypothesis of mine.
If anyone has a better idea, welcome post it.