OpenParable
Skip to content
← Back to skills

Pest Testing

Testing & Quality
pest-testing

Pest Testing is an Agent Skill for testing & quality published in the krayin/laravel-crm repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Use when writing or updating Krayin CRM tests (unit or feature), debugging test failures, using datasets, mocks or custom expectations, writing architecture tests, or when the user mentions test, spec, TDD, expects, assertion, or coverage. Uses the Pest PHP framework (v3) with Laravel 12.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/krayin/laravel-crm/blob/HEAD/.github/skills/pest-testing/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/pest-testing, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Pest Testing in Krayin CRM

When to Apply

Activate this skill when:

  • Creating or updating tests (unit or feature)
  • Debugging test failures
  • Using datasets, mocks, or custom expectations
  • Writing architecture or convention tests
  • The user mentions test, spec, TDD, expects, assertion, coverage, or verifying behavior

Krayin Testing Structure

Test Locations

Krayin tests are stored in the root tests/ directory:

/tests
├── Feature/
├── Unit/
├── Pest.php
├── TestCase.php
└── CreatesApplication.php

Available Test Suites

Defined in phpunit.xml:

Test SuiteLocationCommand
Unittests/Unitphp artisan test --testsuite="Unit"
Featuretests/Featurephp artisan test --testsuite="Feature"

Pest.php Configuration

tests/Pest.php binds the base test case for feature tests:

uses(\Tests\TestCase::class)->in('Feature');

It also defines helper functions you can reuse, such as:

  • getDefaultAdmin()
  • actingAsSanctumAuthenticatedAdmin()
  • getFirstName($fullName)

Running Tests

Run All Tests

php artisan test --compact

Run a Specific Test Suite

php artisan test --testsuite="Feature"
php artisan test --testsuite="Unit"

Run a Specific Test File

php artisan test --compact tests/Feature/ExampleTest.php

Run with Filter

php artisan test --compact --filter=testName

Creating New Tests

Create Feature Test

php artisan make:test --pest ExampleFeatureTest

Create Unit Test

php artisan make:test --pest --unit ExampleUnitTest

Basic Test Structure

it('passes basic assertion', function () {
    expect(true)->toBeTrue();
});

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

    $response->assertSuccessful();
});

Assertions

Prefer specific response helpers:

UseInstead of
assertSuccessful()assertStatus(200)
assertNotFound()assertStatus(404)
assertForbidden()assertStatus(403)

Datasets

it('has valid emails', function (string $email) {
    expect($email)->toContain('@');
})->with([
    'james' => '[email protected]',
    'john'  => '[email protected]',
]);

Common Pitfalls

  • Forgetting to use assertSuccessful() and other specific helpers
  • Skipping --pest when creating tests
  • Ignoring helper utilities already available in tests/Pest.php

Testing Best Practices

  • Cover happy paths, failure paths, and edge cases
  • Keep tests isolated and focused
  • Use factories where available
  • Follow existing test patterns in the repository