A Jest-like snapshot testing library for Go, enabling easy capture and comparison of test outputs.
Go Snaps is a snapshot testing library for Go that enables developers to capture and automatically compare test outputs against stored references. It simplifies testing of complex data structures, UI components, and API responses by reducing the need for manual assertions. Inspired by Jest's snapshot testing, it integrates natively with Go's testing framework.
Go developers writing tests for applications with complex outputs, such as APIs, CLI tools, or data transformation logic, who want to reduce boilerplate and maintain test reliability.
Developers choose Go Snaps for its Jest-like API, support for multiple data formats (JSON, YAML, unstructured), and seamless integration with Go's testing ecosystem, including CI workflows and snapshot management tools.
Jest-like snapshot testing in 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.
Mirrors Jest's snapshot testing with functions like MatchSnapshot and MatchJSON, making it intuitive for developers familiar with JavaScript testing, as highlighted in the README.
Handles structured (JSON, YAML) and unstructured data through dedicated functions and matchers, simplifying tests for complex outputs like API responses.
Automatically fails on CI for missing or differing snapshots and provides update tools via env variables, ensuring reliable test automation in workflows.
Allows overriding snapshot directory, filename, serializers, and formatting with WithConfig, offering fine-grained control over snapshot management.
The MatchInlineSnapshot feature is marked as experimental in the README, indicating instability and potential breaking changes that may deter production use.
Advanced features like cleaning obsolete snapshots require implementing TestMain and calling snaps.Clean, adding boilerplate code compared to simpler assertion libraries.
Known limitations include poor handling of CRLF line endings on Windows and path tracking problems with specific test runs, which can lead to false obsolete snapshot errors.