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
Tabular Assertions

Tabular Assertions Laravel Package

spatie/tabular-assertions

Write readable “tabular assertions” for Pest or PHPUnit by describing expected data as a Markdown-like table and comparing it to actual arrays/collections. Ideal for ordered datasets like time series, financials, or database rows, with clear diffs.

View on GitHub
Deep Wiki
Context7

Write tabular assertions with Pest or PHPUnit

Frequently asked questions about Tabular Assertions
How do I install spatie/tabular-assertions in a Laravel project?
Run `composer require spatie/tabular-assertions` in your project root. No additional configuration is needed—it works with Pest by default and requires a single `use` statement for PHPUnit.
Does this package work with Laravel’s built-in testing helpers like RefreshDatabase?
Yes. Tabular assertions integrate seamlessly with Laravel’s testing utilities. You can use them alongside `RefreshDatabase`, `actingAs()`, or factories without conflicts.
Can I use dynamic values (like timestamps or UUIDs) in my tabular assertions?
Absolutely. Prefix dynamic fields with `#` (e.g., `#id` or `#created_at`) to ignore them during comparison. This works for Eloquent models, API responses, and arrays.
Will this slow down my test suite if I assert thousands of rows?
Performance impact is minimal for typical use cases. However, avoid asserting massive datasets (e.g., 10K+ rows) in a single test—split into smaller chunks or use pagination.
Is spatie/tabular-assertions compatible with Laravel 10 and PHP 8.1+?
Yes, the package officially supports Laravel 8+ and PHP 8.0+. Always test against your project’s baseline (e.g., Laravel 10) to confirm compatibility.
How do I migrate from custom assertion logic to tabular assertions?
Start by replacing nested `foreach` loops or manual array comparisons with `toMatchTable()`. Pilot in 1–2 critical test suites first, then gradually update templates to standardize usage.
Can I use this for API response testing in Laravel?
Yes. Tabular assertions work perfectly with API responses. For example, assert paginated JSON data or nested resource collections using the same Markdown table syntax.
Are there alternatives to spatie/tabular-assertions for Laravel?
For tabular assertions, alternatives are limited. Custom matchers (e.g., Pest’s `expect()` extensions) or libraries like `laravel-test-helpers` exist but lack the readability and flexibility of this package.
How do I handle nested relationships (e.g., orders with items and users) in assertions?
Flatten nested data into a single table or use `toMatchTable()` recursively. For example, assert an order’s items and user data in separate tables or combine them into one.
Does this package support CI/CD pipelines or parallel testing?
Yes. Tabular assertions are lightweight and compatible with CI/CD. They don’t introduce dependencies that would conflict with parallel test execution in tools like Laravel Pint or Pest.
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