Logo di Speeding Up Laravel Tests

Speeding Up Laravel Tests

CommunityPopolare
freekmurze
speeding-up-laravel-tests

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.

Panoramica

Pubblicato dafreekmurze
Repositorydotfiles
Nome della skillspeeding-up-laravel-tests
Stelle
1K
Fork
203
File inclusi
Solo istruzioni
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da freekmurze su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Speeding Up Laravel Tests in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/freekmurze/dotfiles/tree/main/config/claude/skills/speeding-up-laravel-tests
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/freekmurze/dotfiles.git /tmp/dotfiles
mkdir -p .claude/skills
cp -r /tmp/dotfiles/config/claude/skills/speeding-up-laravel-tests .claude/skills/speeding-up-laravel-tests
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Speeding Up Laravel Tests in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Speeding Up Laravel Tests non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Speeding Up Laravel Tests non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Speeding up Laravel tests

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.

When to use

  • Test suite takes more than a few seconds per test on average.
  • CI duration is climbing and you want to knock minutes off.
  • A specific test is slow and you want to audit what it is actually doing.
  • You are onboarding a new project and want a standard checklist.

Environment and config

  • Set BCRYPT_ROUNDS=4 in .env.testing (or phpunit.xml). Default is 12 and hashing dominates auth tests.
  • Disable XDebug. Disable pcov too at scale unless you specifically need coverage.
  • Disable background packages in the testing environment: Pulse, Telescope, Nightwatch, and similar 3rd-party packages that do work on every request/command.
  • Use WithCachedConfig and WithCachedRoutes traits to avoid re-parsing config and routes on every test.
  • Call withoutVite() (or withoutMix()) in your test setup so the framework does not try to resolve built assets.

Fake external interactions

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().
  • HTTP endpoints that dispatch jobs: fake the queue unless the test is asserting job behavior. Otherwise the jobs execute inline and pull in everything they touch.
  • Event listeners: if unrelated listeners are firing and doing work, 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.

Database

  • LazilyRefreshDatabase instead of RefreshDatabase. Tests that never touch the DB skip the migration/truncation cost entirely.
  • Audit factory usage. Factories are a common hotspot because it is easy to create more models than a test needs. Look for nested create() calls spawning extra rows.
  • Use $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.

Profile and diagnose

  • ./vendor/bin/pest --profile prints the slowest tests per shard. Start there. Patterns in the top-10 often apply suite-wide.
  • Visualize the suite with https://marmelab.com/phpunit-d3-report/ (originally PHPUnit; verify Pest compatibility).
  • When a slow test is mysterious, instrument event listeners or add temporary logging to find the unexpected work happening behind the scenes.

Quick reference

AreaAction
HashingBCRYPT_ROUNDS=4
DebuggersDisable XDebug, disable pcov
Background pkgsDisable Pulse, Telescope, Nightwatch
Config / routesWithCachedConfig, WithCachedRoutes
AssetswithoutVite() / withoutMix()
External servicesNotification::fake(), Mail::fake(), Bus::fake(), Event::fake(), Queue::fake()
HTTPHttp::preventingStrayRequests()
SleepSleep::fake(syncWithCarbon: true)
ExceptionsExceptions::fake()
DBLazilyRefreshDatabase
Factories$factory->recycle($model), audit nested creates
Profilingpest --profile

Common mistakes

  • Enabling RefreshDatabase on every test even when the test does not hit the DB.
  • Calling real sleep() or using Carbon in production code, which prevents Sleep::fake() from helping.
  • Adding Queue::fake() but still asserting side effects of the job (those will never happen).
  • Running the suite with XDebug loaded "just in case" a test fails.
  • Leaving BCRYPT_ROUNDS at the default because .env.testing was never created.

Domande frequenti

Cosa fa la skill IA Speeding Up Laravel Tests?

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.

Perché usare Speeding Up Laravel Tests su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Speeding Up Laravel Tests è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Speeding Up Laravel Tests in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/freekmurze/dotfiles/tree/main/config/claude/skills/speeding-up-laravel-tests. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Speeding Up Laravel Tests?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Speeding Up Laravel Tests?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Speeding Up Laravel Tests: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Speeding Up Laravel Tests è gratuita?

È pubblicata su GitHub da freekmurze. Consulta il repository per i termini di licenza. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇