Token导航 LogoToken导航TokenDH.com
开发操作浏览器unknown未标认证来源可访问许可证需确认审计未展示

pest-testing害虫检测

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

374

周安装

15

下载量

121
Local Agent

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:pest-testing(害虫检测)
来源仓库:https://smithery.ai
仓库路径:pest-testing
安装命令:
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。当前暂无明确安装命令,请以来源页面说明为准。

简介

用于辅助测试设计、自动化测试、用例整理和回归验证。

  • 适合编写单元测试、端到端测试或根据日志定位问题。
  • 需确认项目测试框架、运行命令和夹具数据后使用。pest-testing 属于开发类 Skill,可作为该场景下的辅助能力补充。
  • 避免为通过测试而修改真实逻辑,区分模拟与生产环境。
  • 涉及浏览器或服务时,应明确本地、测试和生产环境边界。

SKILL.md

Pest Testing Skill

This skill provides expert guidance for writing high-quality tests with Pest v4 in Laravel applications, covering feature tests, unit tests, browser tests, and testing best practices.

Purpose

Provide comprehensive Pest v4 testing guidance covering:

  • Core Pest syntax and expectations API
  • Feature and unit testing in Laravel
  • Browser testing with Pest v4 (new feature)
  • HTTP testing, authentication, and authorization
  • Database testing and factories
  • Mocking and faking Laravel services
  • Testing best practices and patterns
  • Datasets for efficient test organization

When to Use

Use this skill when:

  • Writing or updating tests
  • Implementing test-driven development (TDD)
  • Testing APIs and HTTP endpoints
  • Testing authentication and authorization
  • Creating browser automation tests
  • Testing with model factories
  • Using datasets to avoid duplicate tests
  • Mocking services or external dependencies
  • Verifying features work correctly
  • Ensuring code quality and preventing regressions

Core Principles

1. Most Tests Should Be Feature Tests

Focus on feature tests that verify complete workflows:

// ✅ GOOD - Feature test testing full workflow
it('creates a post', function () {
    $user = User::factory()->create();

    $response = $this->actingAs($user)->post('/posts', [
        'title' => 'My Post',
        'body' => 'Content',
    ]);

    $response->assertCreated();

    $this->assertDatabaseHas('posts', [
        'title' => 'My Post',
        'user_id' => $user->id,
    ]);
});

// Unit tests are for isolated logic
it('calculates total correctly', function () {
    $calculator = new Calculator();

    expect($calculator->add(2, 2))->toBe(4);
});

2. Always Use Model Factories

Never manually create models - use factories:

// ✅ CORRECT - Use factories
$user = User::factory()->create();
$posts = Post::factory()->count(3)->create();

// Check for factory states
$admin = User::factory()->admin()->create();
$publishedPost = Post::factory()->published()->create();

// ❌ WRONG - Manual creation
$user = User::create([
    'name' => 'Test',
    'email' => 'test@example.com',
    // ... many fields
]);

3. Use Datasets to Avoid Duplication

When testing similar scenarios with different data, use datasets:

// ✅ GOOD - Using dataset
it('validates email format', function (string $email, bool $valid) {
    $validator = validator(['email' => $email], ['email' => 'email']);

    expect($validator->passes())->toBe($valid);
})->with([
    ['valid@example.com', true],
    ['invalid', false],
    ['test@test.co', true],
    ['@example.com', false],
]);

// ❌ WRONG - Duplicate tests
it('accepts valid email', function () {
    $validator = validator(['email' => 'valid@example.com'], ['email' => 'email']);
    expect($validator->passes())->toBeTrue();
});

it('rejects invalid email', function () {
    $validator = validator(['email' => 'invalid'], ['email' => 'email']);
    expect($validator->passes())->toBeFalse();
});

4. Use Specific Assertions

Prefer specific assertions over generic ones:

// ✅ GOOD - Specific assertions
$response->assertOk();           // 200
$response->assertCreated();      // 201
$response->assertNoContent();    // 204
$response->assertNotFound();     // 404
$response->assertForbidden();    // 403
$response->assertUnprocessable();// 422

// ❌ AVOID - Generic assertions
$response->assertStatus(200);
$response->assertStatus(404);

5. Import Mock Function When Needed

Always import the mock function before using it:

use function Pest\Laravel\mock;

it('mocks a service', function () {
    $mock = mock(PaymentService::class);

    $mock->shouldReceive('charge')
        ->once()
        ->andReturn(true);

    // Test code
});

Read references/core.md for complete Pest syntax and expectations API.

Running Tests

Run All Tests

php artisan test

Run Specific File

php artisan test tests/Feature/PostTest.php

Run with Filter

php artisan test --filter=login
php artisan test --filter="can create posts"

Run Specific Group

php artisan test --group=integration

Best Practice: Run the minimal number of tests using an appropriate filter when developing, then run the full suite before committing.

Feature Testing Patterns

Basic HTTP Testing

it('displays homepage', function () {
    $response = $this->get('/');

    $response->assertOk()
        ->assertSee('Welcome');
});

it('creates resource', function () {
    $user = User::factory()->create();

    $response = $this->actingAs($user)->post('/posts', [
        'title' => 'My Post',
        'body' => 'Content',
    ]);

    $response->assertCreated()
        ->assertJson(['title' => 'My Post']);
});

Authentication Testing

it('requires authentication', function () {
    $response = $this->get('/dashboard');

    $response->assertRedirect('/login');
});

it('allows authenticated users', function () {
    $user = User::factory()->create();

    $response = $this->actingAs($user)->get('/dashboard');

    $response->assertOk();
});

Validation Testing

it('validates required fields', function () {
    $user = User::factory()->create();

    $response = $this->actingAs($user)->post('/posts', []);

    $response->assertUnprocessable()
        ->assertJsonValidationErrors(['title', 'body']);
});

Read references/laravel.md for comprehensive Laravel testing patterns.

Pest v4 Browser Testing

Pest v4 introduces powerful browser testing capabilities:

use function Pest\Laravel\visit;

it('can login', function () {
    $user = User::factory()->create([
        'password' => bcrypt('password'),
    ]);

    $page = visit('/login');

    $page->fill('email', $user->email)
        ->fill('password', 'password')
        ->click('Login')
        ->assertPath('/dashboard')
        ->assertSee("Welcome, {$user->name}");
});

Browser Testing Features

  • Real browser testing - Chrome, Firefox, Safari
  • JavaScript support - Full JS execution
  • Multiple devices - Test on different viewports/devices
  • Dark mode testing - Test light and dark color schemes
  • Screenshots - Capture on failure or manually
  • Touch gestures - Test mobile interactions
  • Wait utilities - Wait for dynamic content

Browser Test Best Practices

it('has no JavaScript errors', function () {
    $pages = visit(['/', '/about', '/contact']);

    $pages->assertNoJavascriptErrors()
        ->assertNoConsoleLogs();
});

it('works in dark mode', function () {
    $page = visit('/', colorScheme: 'dark');

    $page->assertSee('Welcome')
        ->assertNoJavascriptErrors();
});

it('works on mobile', function () {
    $page = visit('/', device: 'iPhone 14 Pro');

    $page->assertSee('Welcome')
        ->assertVisible('.mobile-menu');
});

Read references/browser.md for comprehensive browser testing guide.

Using Model Factories

Basic Factory Usage

// Single model
$user = User::factory()->create();

// Multiple models
$users = User::factory()->count(5)->create();

// With specific attributes
$user = User::factory()->create([
    'name' => 'John Doe',
    'email' => 'john@example.com',
]);

// With relationships
$user = User::factory()
    ->has(Post::factory()->count(3))
    ->create();

Using Factory States

Check if factories have custom states before manually setting attributes:

// Check factory for states like:
$admin = User::factory()->admin()->create();
$publishedPost = Post::factory()->published()->create();
$verifiedUser = User::factory()->verified()->create();

Testing with RefreshDatabase

Clean database state between tests:

use Illuminate\Foundation\Testing\RefreshDatabase;

uses(RefreshDatabase::class);

it('creates user', function () {
    $user = User::factory()->create();

    expect(User::count())->toBe(1);
});

Mocking and Faking

Faking Laravel Services

use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Storage;

it('sends email', function () {
    Mail::fake();

    // Trigger email

    Mail::assertSent(WelcomeEmail::class);
});

it('dispatches job', function () {
    Queue::fake();

    // Trigger job

    Queue::assertPushed(ProcessPodcast::class);
});

it('dispatches event', function () {
    Event::fake();

    // Trigger event

    Event::assertDispatched(UserCreated::class);
});

Mocking Classes

use function Pest\Laravel\mock;

it('mocks external service', function () {
    $mock = mock(PaymentGateway::class);

    $mock->shouldReceive('charge')
        ->once()
        ->with(100)
        ->andReturn(['status' => 'success']);

    // Test code that uses PaymentGateway
});

Test Organization

Grouping Related Tests

describe('User Management', function () {
    it('creates users', function () {
        //
    });

    it('updates users', function () {
        //
    });

    it('deletes users', function () {
        //
    });
});

Using Tags/Groups

it('is an integration test', function () {
    //
})->group('integration');

it('is slow', function () {
    //
})->group('slow', 'integration');

// Run: php artisan test --group=integration

Reference Files

This skill includes detailed reference files:

  • references/core.md - Pest syntax, expectations API, assertions, datasets, mocking, lifecycle hooks
  • references/browser.md - Browser testing, interactions, waiting, device testing, screenshots, smoke testing
  • references/laravel.md - HTTP testing, authentication, validation, database testing, faking services

Read the appropriate reference file(s) when working on specific testing tasks.

Testing Workflow

Test-Driven Development (TDD)

  1. Write failing test - Define expected behavior
  2. Write minimal code - Make test pass
  3. Refactor - Improve code while keeping tests green
  4. Repeat - For next feature or behavior

Testing Existing Features

  1. Write test for happy path - Normal, successful flow
  2. Write test for failure paths - Error cases, validation failures
  3. Write test for edge cases - Empty data, null values, boundaries
  4. Run tests - Verify all pass
  5. Refactor if needed - Improve while keeping tests green

Best Practices Summary

  1. Write feature tests - Most tests should test complete workflows
  2. Use factories - Always use model factories for test data
  3. Use datasets - Avoid duplicate tests with different data
  4. Use specific assertions - assertOk() not assertStatus(200)
  5. Import mock function - use function Pest\Laravel\mock;
  6. Use RefreshDatabase - Clean database between tests
  7. Check factory states - Use existing states before manual setup
  8. Test all paths - Happy, failure, and edge cases
  9. Run minimal tests - Use filters when developing
  10. Run full suite - Before committing changes
  11. Use browser tests - For JavaScript-heavy features
  12. Check for JS errors - Use assertNoJavascriptErrors()
  13. Test both themes - Verify light and dark modes
  14. Keep tests isolated - Each test should be independent
  15. Use descriptive names - Tests should read like specifications

Common Testing Tasks

Testing a New Feature

  1. Create test file: php artisan make:test FeatureTest --pest
  2. Write test for expected behavior
  3. Run test: php artisan test --filter=FeatureName
  4. Implement feature
  5. Verify test passes
  6. Add tests for edge cases
  7. Run full suite: php artisan test

Testing API Endpoints

  1. Test successful requests (2xx status)
  2. Test validation errors (422 status)
  3. Test authentication (401/403 status)
  4. Test not found (404 status)
  5. Verify JSON structure and data
  6. Test with different user permissions

Testing Browser Interactions

  1. Create browser test in tests/Browser/
  2. Visit the page
  3. Interact with elements (click, type, select)
  4. Assert expected results
  5. Check for JavaScript errors
  6. Test on different devices/viewports
  7. Test both color schemes

This skill ensures tests are comprehensive, maintainable, and follow Pest v4 best practices for Laravel applications.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Local Agent

73.81%
按下载量换算89

安全审计

暂无安全审计结果可展示。

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills