A concise, declarative Go library for end-to-end HTTP and REST API testing with chainable request builders and assertions.
httpexpect is a Go testing library for end-to-end HTTP and REST API testing. It provides a fluent, chainable interface for building HTTP requests and making assertions on responses, making API tests more readable and maintainable. The library supports testing via real HTTP clients or by directly invoking HTTP handlers, and includes features like WebSocket testing, JSON Schema validation, and detailed error reporting.
Go developers writing integration or end-to-end tests for HTTP servers, REST APIs, and WebSocket services. It is particularly useful for teams needing expressive, declarative test syntax that integrates with Go's standard testing tools.
Developers choose httpexpect for its comprehensive feature set, including WebSocket support, JSONPath queries, and JSON Schema validation, combined with a fluent API that improves test readability. Its flexibility in testing approaches—via real HTTP or direct handler invocation—and detailed, configurable error output make it stand out from simpler assertion libraries.
End-to-end HTTP and REST API testing for Go.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Includes support for WebSocket testing, JSON Schema validation, and JSONPath queries, as detailed in the README's features section, going beyond basic HTTP assertions.
Allows testing via real HTTP client or direct handler invocation for frameworks like net/http, fasthttp, Gin, and Echo, demonstrated in multiple examples.
Provides verbose error messages with JSON diffs using gojsondiff and color support via fatih/color, making debugging easier with configurable printers.
Offers a declarative, chainable API that improves test readability, with builders and assertions shown in the quick start examples for intuitive test writing.
Relies on multiple third-party libraries such as gorilla/websocket, gojsonschema, and go-querystring, which can increase project complexity and potential versioning issues.
Setting up custom clients, formatters, and assertion handlers requires more initial effort, as seen in the extensive configuration examples and tuning sections.
Major version updates may introduce backwards-incompatible changes, requiring test updates, as noted in the versioning section with separate stable branches.