Best for
- Feature tests
- Unit tests
- API endpoint tests
event4u-app/agent-config/src/skills/pest-testing/SKILL.md
Use when writing, generating, or improving Pest tests for Laravel — clear intent, good coverage, maintainable structure, and alignment with project testing conventions.
Decision brief
Use when writing, generating, or improving Pest tests for Laravel — clear intent, good coverage, maintainable structure, and alignment with project testing conventions.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/event4u-app/agent-config --skill "src/skills/pest-testing"Inspect the Agent Skill "pest-testing" from https://github.com/event4u-app/agent-config/blob/0adf49a8ae84b0ff6e2de8759eea43257e020eff/src/skills/pest-testing/SKILL.md at commit 0adf49a8ae84b0ff6e2de8759eea43257e020eff. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
1. Read the base skills first — apply php-coder, laravel, and eloquent where relevant. 2. Check the project's test framework — confirm Pest is used and inspect existing tests. 3. Match the current test style — naming, helpers, datasets, expectations, setup, traits, and folder st…
For bug fixes and new features, prefer test-driven development:
Review the “Example test usage” section in the pinned source before continuing.
Mock external boundaries (APIs, file systems, third-party services).
Use this skill for all Laravel testing tasks, especially when working with:
Permission review
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 98/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 7 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Use this skill for all Laravel testing tasks, especially when working with:
This skill extends php-coder, laravel, and eloquent.
For prevention layers that fire before writing a test — TDD
discipline, mock-isolation gates, and the 12 process rationalizations
("I'll add the test after", "patch first, test later") — see
test-driven-development,
testing-anti-patterns, and
process-anti-patterns.md.
php-coder, laravel, and eloquent where relevant.test-case-discovery funnel; floor per behavior: 1 happy + 1 boundary + 1 error (+1 abuse on security paths).For bug fixes and new features, prefer test-driven development:
Tests written after implementation pass immediately. Passing immediately proves nothing:
For every bug fix: write a failing test that reproduces the bug FIRST, then fix it. The test proves the fix works AND prevents regression.
| Excuse | Reality |
|---|---|
| "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
| "I'll test after" | Tests passing immediately prove nothing. |
| "Manual test is faster" | Manual doesn't prevent regression. You'll re-test every change. |
| "Test is hard to write" | Hard to test = hard to use. Simplify the design. |
| "Need to explore first" | Fine — throw away exploration code, start fresh with TDD. |
| "Existing code has no tests" | You're improving it. Add tests for what you touch. |
RefreshDatabase or the project's standard database reset strategy where appropriate.it() / test() according to existing project conventions.readonly or final on Pest test classes.final if they need to be mocked via Mockery::mock().namespace declaration) treat all PHP built-in classes as global.
Do NOT add use statements for global classes like DateTimeImmutable, Exception,
stdClass, etc. — PHP will warn: "The use statement with non-compound name has no effect".use statements for namespaced classes (e.g., use App\Models\...) are needed.$this->travel(5)->seconds() (Laravel's time travel) to create
a clear gap between "before" and "after" timestamps. Never rely on now() being different
between two lines of code — on fast hardware, they can be identical.null just because the seeder
doesn't set them — previous tests in parallel may have modified the same record.200 — verify meaningful behavior.assertDatabaseHasassertDatabaseMissingcoduo/php-matcherThis project uses coduo/php-matcher for flexible snapshot assertions.
Pattern files live in snapshots/ directories next to the test files.
Use pattern variables instead of hardcoded values in snapshot files. This makes snapshots resilient to data changes while still enforcing type correctness.
| Pattern | Matches | Example |
|---|---|---|
@boolean@ | true or false | 'is_active' => '@boolean@' |
@integer@ | Any integer | 'id' => '@integer@' |
@string@ | Any string | 'name' => '@string@' |
@null@ | null | 'deleted_at' => '@null@' |
@datetime@ | ISO datetime string | 'created_at' => '@datetime@' |
@uuid@ | UUID string | 'uuid' => '@uuid@' |
@array@ | Any array | 'items' => '@array@' |
@double@ | Any float | 'amount' => '@double@' |
@wildcard@ | Anything | 'data' => '@wildcard@' |
Combine with || for nullable fields: 'deleted_at' => '@null@||@datetime@'
$replacements.false) when other booleans in the same file use @boolean@ — be consistent.$variable ?? '@pattern@' syntax to allow test-specific overrides via replacements parameter.PhpMatcherHelper::ruleBackedEnum(EnumClass::class, 'string') for enum fields.// snapshots/user-resource.php
return [
'id' => $id ?? '@integer@',
'name' => $name ?? '@string@',
'email' => $email ?? '@string@',
'is_active' => $is_active ?? '@boolean@',
'created_at' => $created_at ?? '@datetime@',
'deleted_at' => $deleted_at ?? '@null@||@datetime@',
];
expect($response->json())
->toMatchPhpPatternFile(
patternFile: __DIR__ . '/snapshots/user-resource.php',
replacements: ['id' => $user->getId()],
);
Queue::fake()Bus::fake()Event::fake()Mail::fake()Notification::fake()Storage::fake()When reviewing or auditing existing tests, check for these anti-patterns:
| Smell | Description | Fix |
|---|---|---|
| Overmocking | Too many mocks disconnect the test from reality | Replace mocks with real implementations or fakes |
| Fragile tests | Tests break with unrelated changes (e.g., asserting exact JSON structure) | Assert only meaningful fields |
| Flaky tests | Non-deterministic results (time, ordering, parallel state) | Use time travel, explicit ordering, isolated data |
| Giant tests | One test covers 5+ behaviors | Split into focused tests |
| Missing assertions | Test runs code but doesn't verify outcomes | Add meaningful assertions |
| Test duplication | Same scenario tested in multiple places | Consolidate or use datasets |
| Assertion roulette | Many assertions without clear failure messages | Use named assertions or split tests |
| Eager test | Tests too many things, making failures hard to diagnose | One behavior per test |
Queue::fake(), Http::fake()) over manual mocks.When generating Pest tests:
When triaging a verbose run, narrow the output with --filter (Pest)
plus targeted grep/rg instead of re-running the whole suite or
echoing all logs:
# Only run failing tests in one file
vendor/bin/pest tests/Feature/InvoiceTest.php --filter='creates invoice'
# Scan the test log for failures only
rg --color=never '^FAIL|Tests:' storage/logs/pest.log
# Inspect JSON output from data-driven tests
vendor/bin/pest --log-junit=pest.xml && rg '<failure' pest.xml
readonly or final on Pest test helper classes — it breaks mocking.use statements for global classes (Exception, DateTimeImmutable) in Pest files — they're auto-imported.$this->travel(5)->seconds() for time-dependent tests — never rely on now() differing between lines.When generating new tests, focus on:
What NOT to test:
Quality over quantity — 5 meaningful tests beat 20 trivial ones.
Alternatives
event4u-app/agent-config
Use when the user says "review the design", "check the UI", or wants a comprehensive UI/UX review. Uses a 7-phase methodology covering interaction, responsiveness, accessibility, and more.
affaan-m/ECC
Test-driven development for Quarkus 3.x LTS using JUnit 5, Mockito, REST Assured, Camel testing, and JaCoCo. Use when adding features, fixing bugs, or refactoring event-driven services.
github/awesome-copilot
Expert-level Windows batch file (.bat/.cmd) skill for writing, debugging, and maintaining CMD scripts. Use when asked to "create a batch file", "write a .bat script", "automate a Windows task", "CMD scripting", "batch automation", "scheduled task script", "Windows shell script", or when working with .bat/.cmd files in the workspace. Covers cmd.exe syntax, environment variables, control flow, string processing, error handling, and integration with system tools.
github/awesome-copilot
Write and review unit tests for Vue 3 + TypeScript + Vitest + Pinia codebases. Use when creating or updating tests for components, composables, and stores; mocking Pinia with createTestingPinia; applying Vue Test Utils patterns; and enforcing black-box assertions over implementation details.