Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Require: HTTP mock tester #535

Closed
axetroy opened this issue Jul 11, 2019 · 2 comments
Closed

Feature Require: HTTP mock tester #535

axetroy opened this issue Jul 11, 2019 · 2 comments

Comments

@axetroy
Copy link
Contributor

axetroy commented Jul 11, 2019

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

@zekth
Copy link
Contributor

zekth commented Jul 11, 2019

To add for ref i like the Fastify implementation inject. Ref: https://github.com/fastify/fastify/blob/master/docs/Testing.md

@ry
Copy link
Member

ry commented Jul 12, 2019

@axetroy How do they do this within the Go standard library?

inverted-capital pushed a commit to dreamcatcher-tech/napps that referenced this issue Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants