Tdd with pest

From jpcaparas/superpowers-laravel · View interactive version

Tdd with pest is an AI agent skill from the GitHub repository jpcaparas/superpowers-laravel. Apply RED-GREEN-REFACTOR with Pest or PHPUnit; use factories, feature tests for HTTP, and parallel test runners; verify failures before implementation

How to use this skill

Skill file

Laravel TDD (Pest/PHPUnit)

Write the test first. Watch it fail. Write minimal code to pass. Keep tests fast and realistic.

Test Runner

# Sail
sail artisan test --parallel

# Non-Sail
php artisan test --parallel

Prefer Pest (default in new Laravel apps). PHPUnit is fine if your project uses it.

RED – Write a failing test

Example (feature):

it('rejects empty email on signup', function () {
    $response = $this->post('/register', [
        'name' => 'Alice',
        'email' => '',
        'password' => 'secret',
        'password_confirmation' => 'secret',
    ]);

    $response->assertSessionHasErrors('email');
});

Run and confirm it fails for the right reason.

GREEN – Minimal implementation

Write the simplest code to pass your failing test. No extras. No refactors.

REFACTOR – Clean up

Remove duplication, clarify names, extract small services. Keep tests green.

Guidelines

When stuck

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.