Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpunit Snapshot Assertions Laravel Package

spatie/phpunit-snapshot-assertions

Add snapshot testing to PHPUnit with simple assertions for JSON, XML, and text. First run creates snapshots; later runs compare outputs and fail on regressions. Ideal for verifying serialized data and responses with minimal test boilerplate.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit: Excellent for Laravel projects as it integrates directly with PHPUnit (Laravel's default testing framework) without requiring architectural changes. The trait-based usage aligns with Laravel's testing patterns.
Integration feasibility: High - single composer require --dev command, minimal code changes (add trait to test classes), and no infrastructure dependencies.
Technical risk: Low. Mature package (Spatie maintains it), MIT license, active CI/CD, and backward compatibility maintained (e.g., PHPUnit 9.6+ support). Primary risk is snapshot management in CI (e.g., accidental snapshot updates causing false failures).
Key questions: How will snapshot files be versioned in Git? What's the process for approving snapshot changes in PRs? How will binary snapshots (images) impact repository size? How to handle parallel test execution safely?

Integration Approach

Stack fit: Native compatibility with Laravel's testing stack. Works with Pest (via PHPUnit compatibility) and standard PHPUnit-based tests. No framework-specific adaptations needed.
Migration path: Start with new tests using snapshot assertions for complex data (JSON responses, HTML rendering). Gradually convert existing unit tests for high-value scenarios (e.g., API payloads, serialization logic) during maintenance cycles.
Compatibility: Fully compatible with PHPUnit 9.6+ and 13 (per changelog). Works with Laravel 8+ (which supports these PHPUnit versions). No conflicts with common testing tools like Pest or Paratest when using environment flags.
Sequencing: 1) Install package and configure .gitattributes for Windows line endings. 2) Enable snapshot creation in local development. 3) Convert high-risk tests first. 4) Configure CI to run with CREATE_SNAPSHOTS=false for validation. 5) Implement snapshot update workflow for PRs (e.g., manual approval via env var).

Operational Impact

Maintenance: Low overhead. Package requires minimal updates (only when PHPUnit versions change). Snapshot files must be committed to Git and monitored for bloat (especially binary files). Spatie's active maintenance reduces support burden.
Support: Strong community support via Spatie's documentation and GitHub. MIT license allows unlimited usage without vendor dependency. Clear error messages guide troubleshooting (e.g., explicit instructions when snapshots are missing in CI).
Scaling: Handles large test suites efficiently. Snapshot storage scales linearly with tests (text snapshots are small; image snapshots require storage planning). Parallel testing works with CREATE_SNAPSHOTS env var configuration.
Failure modes: False failures occur if snapshots aren't updated after legitimate changes. Binary snapshot diffs (e.g., images) require manual comparison. Repository bloat from unmanaged binary snapshots is possible if not monitored.
Ramp-up: Minimal learning curve. Laravel developers can start using it in <1 day. Documentation includes clear examples for common use cases (JSON, HTML, images). Existing PHPUnit knowledge transfers directly.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport