{
  "id": 21063367,
  "title": "Faster Laravel tests: restore a snapshot instead of running migrate:fresh",
  "url": "https://urgent.news/2026/11/21/faster-laravel-tests-restore-a-snapshot-instead-of-running-migrate",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-21T15:30:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/amjadiqbal/faster-laravel-tests-restore-a-snapshot-instead-of-running-migratefresh-2e0d"
  },
  "original_language": "en",
  "account": "Laravel's RefreshDatabase runs the migrate:fresh command in every test process, consuming valuable time. The Refresher open-source package offers a solution by saving and reusing the test database snapshot. After the first test process completes, subsequent processes restore the snapshot until a migration, seeder, or factory changes. SQLite snapshots are file copies, while MySQL and MariaDB utilize mysqldump and the mysql client. To implement the snapshot feature, require the package via Composer, extend the Testcase class with the Refresher trait in Pest, and use the LazilyRefreshesWithRefresher trait in PHPUnit. Benchmark tests show significant improvements in test times - Pinkary (MySQL, 60 migrations) drops from 3.95 seconds to 1.87 seconds per test process, Filament Demo (SQLite, 37 migrations) reduces from 1.37 seconds to 1.18 seconds. For better performance, limit to small schemas without seeders, as PostgreSQL is currently unsupported and in-memory SQLite still migrates in every process. Write seeders files, clear the cache manually with php artisan refresher:clear, and check out the documentation at urlshortly.com/VWOIO.",
  "summary": "Laravel's RefreshDatabase runs migrate:fresh once in every test process: every single-test run, every CI job and every --parallel worker. Refresher is an open-source drop-in replacement that does it once and reuses the result. How it works The first test process migrates (and seeds) the test database and saves it as a snapshot. Every process after that restores the snapshot, until a migration,…",
  "key_points": [
    "Laravel's RefreshDatabase runs migrate:fresh in every test process",
    "Refresher package saves and reuses test database snapshot",
    "Benchmark shows significant improvements in test times"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}