group('{{capability}}'); /* * Test Template for Pest Feature Tests * * Copy this file and replace: * - {{capability}} with the capability name (e.g., 'authentication') * - {{scenario_description}} with the spec scenario description * * Mark pending tests with ->todo() during Red Phase * Remove ->todo() and implement during Green Phase */ describe('{{capability}} API', function () { // Use RefreshDatabase trait for clean state uses(RefreshDatabase::class); beforeEach(function () { // Setup code runs before each test // e.g., create test user, authenticate, etc. }); /* * Scenario: {{scenario_description}} * * Spec Reference: specs/{{capability}}/spec.md * Scenario: {{scenario_number}} */ it('{{scenario_description}}', function () { // Arrange (GIVEN) // Set up the initial state // Act (WHEN) // Perform the action $response = $this->postJson('/api/{{endpoint}}', [ // Request data ]); // Assert (THEN) // Verify the expected outcome $response->assertStatus(200) ->assertJson([ // Expected response structure ]); })->todo(); // Remove ->todo() when implementing /* * Example: Error scenario */ it('returns error when {{error_condition}}', function () { // Arrange // Act $response = $this->postJson('/api/{{endpoint}}', [ 'invalid' => 'data' ]); // Assert $response->assertStatus(422) ->assertJsonValidationErrors(['field_name']); })->todo(); /* * Example: Authorization scenario */ it('returns 403 when user lacks permission', function () { // Arrange: Create user without permission $user = User::factory()->create(['role' => 'developer']); // Act $response = $this->actingAs($user) ->postJson('/api/{{admin_endpoint}}'); // Assert $response->assertStatus(403); })->todo(); }); /* * Helper functions specific to this capability */ function create{{model}}(array $attributes = []): {{model}} { return {{model}}::factory()->create($attributes); } function authenticateUser(string $role = 'manager'): User { $user = User::factory()->create(['role' => $role]); // Return authenticated user or token return $user; }