Skip to content

🚀 How about compatibling with httpexpect #485

Closed
@kiyonlin

Description

@kiyonlin

Is your feature request related to a problem?
No

Describe the solution you'd like
httpexpect already supports fasthttp binder.

The only thing to do is making app.handler accessable.

Simple example:

// fiberHTTPTester returns a new Expect instance to test FiberHandler().
func fiberHTTPTester(t *testing.T) *httpexpect.Expect {
	app := fiber.New()
	app.Get("ping", func(c *fiber.Ctx) {
		c.SendString("pong")
	})
	return httpexpect.WithConfig(httpexpect.Config{
		Client:   &http.Client{Transport: httpexpect.NewFastBinder(app.Handler)},
		Reporter: t,
	})
}

func TestFastHTTP(t *testing.T) {
	e := fiberHTTPTester(t)

	e.GET("/ping").Expect().
		Status(200).
		Text().Equal("pong")
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions