test-driven-development
OBobra/superpowers298k2,631 new stars in the last 7 days
Use when Laravel/Pest test suites are slow, CI duration is growing, individual tests take seconds, or the user asks to speed up, optimize, or profile tests. Covers factories, fakes, config caching, XDebug/pcov, BCRYPT_ROUNDS, LazilyRefreshDatabase, and stray HTTP requests.
A curated list of techniques for making Laravel test suites faster. Apply these in roughly the order shown; environment fixes usually give the biggest wins for the least effort.
BCRYPT_ROUNDS=4 in .env.testing (or phpunit.xml). Default is 12 and hashing dominates auth tests.WithCachedConfig and WithCachedRoutes traits to avoid re-parsing config and routes on every test.withoutVite() (or withoutMix()) in your test setup so the framework does not try to resolve built assets.Any interaction with an outside service that is not the subject of the test should be faked.
Notification::fake(), Mail::fake(), Bus::fake(), Event::fake(), Queue::fake().Event::fake() them. Use Laravel's event system to discover what is being triggered during a slow test.Http::preventingStrayRequests() in your test suite. A single slow stray request can punish every test. Note this only catches requests made through Laravel's HTTP client. Audit direct Guzzle / cURL usage separately.Sleep::fake(syncWithCarbon: true) so retries and backoffs do not actually sleep. Requires your code to use the Sleep helper rather than PHP's sleep().Exceptions::fake() to make sure you are not reporting to Flare/Sentry/Bugsnag from within tests.LazilyRefreshDatabase instead of RefreshDatabase. Tests that never touch the DB skip the migration/truncation cost entirely.create() calls spawning extra rows.$factory->recycle($model) to create a shared parent once and thread it through nested factory calls, instead of each nested factory creating its own parent../vendor/bin/pest --profile prints the slowest tests per shard. Start there. Patterns in the top-10 often apply suite-wide.| Area | Action |
|---|---|
| Hashing | BCRYPT_ROUNDS=4 |
| Debuggers | Disable XDebug, disable pcov |
| Background pkgs | Disable Pulse, Telescope, Nightwatch |
| Config / routes | WithCachedConfig, WithCachedRoutes |
| Assets | withoutVite() / withoutMix() |
| External services | Notification::fake(), Mail::fake(), Bus::fake(), Event::fake(), Queue::fake() |
| HTTP | Http::preventingStrayRequests() |
| Sleep | Sleep::fake(syncWithCarbon: true) |
| Exceptions | Exceptions::fake() |
| DB | LazilyRefreshDatabase |
| Factories | $factory->recycle($model), audit nested creates |
| Profiling | pest --profile |
RefreshDatabase on every test even when the test does not hit the DB.sleep() or using Carbon in production code, which prevents Sleep::fake() from helping.Queue::fake() but still asserting side effects of the job (those will never happen).BCRYPT_ROUNDS at the default because .env.testing was never created.OBobra/superpowers298k2,631 new stars in the last 7 days
MAmattpocock/skills288k10,178 new stars in the last 7 days
AFaffaan-m/ECC278k4,046 new stars in the last 7 days
Audit accessibility on Web, iOS, and Android to meet WCAG 2.2, with keyboard navigation and screen-reader support.
AFaffaan-m/ECC278k4,046 new stars in the last 7 days
AFaffaan-m/ECC278k4,046 new stars in the last 7 days
FIfirecrawl/firecrawl191k2,010 new stars in the last 7 days