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.
DatabaseMigrations, RefreshDatabase) and factories (as shown in the example), reducing friction in test setup.# for dynamic fields (as shown in the example).assertEquals)?/orders endpoint returning paginated data).actingAs(), withoutExceptionHandling()).use Spatie\TabularAssertions\TabularAssertions).#id).foreach loops) in favor of tabular assertions.composer require.composer.json and run composer update.toMatchTable() (example provided in README).# for dynamic fields).composer.json if stability is critical (e.g., regulated industries).dd() to inspect the actual data structure before asserting.spatie/tabular-assertions) are active.--parallel flag.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Incorrect table syntax | Test flakiness | Lint tables with a Markdown validator. |
Dynamic field (#id) mismatch |
False negatives | Use ->where() to filter data before asserting. |
| Large table assertions | Slow test suite | Split into smaller assertions or use sampling. |
| Dependency conflicts (unlikely) | Build failures | Test in isolation before full integration. |
assertArrayHasKey).How can I help you explore Laravel packages today?