pest-testing
Tests applications using the Pest 4 PHP framework. Activates when writing tests, creating unit or feature tests, adding assertions, testing Livewire components, browser testing, debugging test failures, working with datasets or mocking; or when the user mentions test, spec, TDD, expects, assertion, coverage, or needs to verify functionality works.
Install
mkdir -p .claude/skills/pest-testing && curl -L -o skill.zip "https://mcp.directory/api/skills/download/5619" && unzip -o skill.zip -d .claude/skills/pest-testing && rm skill.zipInstalls to .claude/skills/pest-testing
About this skill
Pest Testing 4
When to Apply
Activate this skill when:
- Creating new tests (unit, feature, or browser)
- Modifying existing tests
- Debugging test failures
- Working with browser testing or smoke testing
- Writing architecture tests or visual regression tests
Documentation
Use search-docs for detailed Pest 4 patterns and documentation.
Basic Usage
Creating Tests
All tests must be written using Pest. Use php artisan make:test --pest {name}.
Test Organization
- Unit/Feature tests:
tests/Featureandtests/Unitdirectories. - Browser tests:
tests/Browser/directory. - Do NOT remove tests without approval - these are core application code.
Basic Test Structure
<code-snippet name="Basic Pest Test Example" lang="php">it('is true', function () { expect(true)->toBeTrue(); });
</code-snippet>Running Tests
- Run minimal tests with filter before finalizing:
php artisan test --compact --filter=testName. - Run all tests:
php artisan test --compact. - Run file:
php artisan test --compact tests/Feature/ExampleTest.php.
Assertions
Use specific assertions (assertSuccessful(), assertNotFound()) instead of assertStatus():
it('returns all', function () { $this->postJson('/api/docs', [])->assertSuccessful(); });
</code-snippet>| Use | Instead of |
|---|---|
assertSuccessful() | assertStatus(200) |
assertNotFound() | assertStatus(404) |
assertForbidden() | assertStatus(403) |
Mocking
Import mock function before use: use function Pest\Laravel\mock;
Datasets
Use datasets for repetitive tests (validation rules, etc.):
<code-snippet name="Pest Dataset Example" lang="php">it('has emails', function (string $email) { expect($email)->not->toBeEmpty(); })->with([ 'james' => 'james@laravel.com', 'taylor' => 'taylor@laravel.com', ]);
</code-snippet>Pest 4 Features
| Feature | Purpose |
|---|---|
| Browser Testing | Full integration tests in real browsers |
| Smoke Testing | Validate multiple pages quickly |
| Visual Regression | Compare screenshots for visual changes |
| Test Sharding | Parallel CI runs |
| Architecture Testing | Enforce code conventions |
Browser Test Example
Browser tests run in real browsers for full integration testing:
- Browser tests live in
tests/Browser/. - Use Laravel features like
Event::fake(),assertAuthenticated(), and model factories. - Use
RefreshDatabasefor clean state per test. - Interact with page: click, type, scroll, select, submit, drag-and-drop, touch gestures.
- Test on multiple browsers (Chrome, Firefox, Safari) if requested.
- Test on different devices/viewports (iPhone 14 Pro, tablets) if requested.
- Switch color schemes (light/dark mode) when appropriate.
- Take screenshots or pause tests for debugging.
it('may reset the password', function () { Notification::fake();
$this->actingAs(User::factory()->create());
$page = visit('/sign-in');
$page->assertSee('Sign In')
->assertNoJavascriptErrors()
->click('Forgot Password?')
->fill('email', 'nuno@laravel.com')
->click('Send Reset Link')
->assertSee('We have emailed your password reset link!');
Notification::assertSent(ResetPassword::class);
});
</code-snippet>Smoke Testing
Quickly validate multiple pages have no JavaScript errors:
<code-snippet name="Pest Smoke Testing Example" lang="php">$pages = visit(['/', '/about', '/contact']);
$pages->assertNoJavascriptErrors()->assertNoConsoleLogs();
</code-snippet>Visual Regression Testing
Capture and compare screenshots to detect visual changes.
Test Sharding
Split tests across parallel processes for faster CI runs.
Architecture Testing
Pest 4 includes architecture testing (from Pest 3):
<code-snippet name="Architecture Test Example" lang="php">arch('controllers') ->expect('App\Http\Controllers') ->toExtendNothing() ->toHaveSuffix('Controller');
</code-snippet>Common Pitfalls
- Not importing
use function Pest\Laravel\mock;before using mock - Using
assertStatus(200)instead ofassertSuccessful() - Forgetting datasets for repetitive validation tests
- Deleting tests without approval
- Forgetting
assertNoJavascriptErrors()in browser tests
More by spatie
View all skills by spatie →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversUnlock AI-ready web data with Firecrawl: scrape any website, handle dynamic content, and automate web scraping for resea
Enhance productivity with AI-driven Notion automation. Leverage the Notion API for secure, automated workspace managemen
Cipher empowers agents with persistent memory using vector databases and embeddings for seamless context retention and t
Quickly rp prototype web apps with Scaffold Generator: create consistent scaffolding using templates, variable substitut
Access chat completions with accurate citations using the Perplexity API. Enhance your applications with reliable AI-pow
Easily manage, deploy, and monitor cloud resources on DigitalOcean using natural language commands for streamlined cloud
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.