Speeding Up Laravel Tests logo

Speeding Up Laravel Tests

CommunityPopular
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.

Overview

Publisherfreekmurze
Repositorydotfiles
Skill namespeeding-up-laravel-tests
Stars
1K
Forks
203
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by freekmurze on GitHub. Read the source before you install it.

Installation

Install the Speeding Up Laravel Tests AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/freekmurze/dotfiles/tree/main/config/claude/skills/speeding-up-laravel-tests
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Speeding Up Laravel Tests in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Speeding Up Laravel Tests on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Speeding Up Laravel Tests is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

Frequently asked questions

What does the Speeding Up Laravel Tests AI skill do?

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.

Why use Speeding Up Laravel Tests on TypingMind?

Because you install it once and use it with any model. Speeding Up Laravel Tests is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Speeding Up Laravel Tests in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/freekmurze/dotfiles/tree/main/config/claude/skills/speeding-up-laravel-tests. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Speeding Up Laravel Tests?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Speeding Up Laravel Tests?

As many as you like. As long as a model supports skills, you can use Speeding Up Laravel Tests with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Speeding Up Laravel Tests AI skill free?

It is published on GitHub by freekmurze. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇