name: 'step-04a-subprocess-api-failing' description: 'Subprocess: Generate FAILING API tests (TDD red phase)' subprocess: true
This is an isolated subprocess running in parallel with E2E failing test generation.
What you have from parent workflow:
Your task: Generate API tests that will FAIL because the feature is not implemented yet (TDD RED PHASE).
From the story acceptance criteria (Step 1 output), identify:
Example Acceptance Criteria:
Story: User Registration
- As a user, I can POST to /api/users/register with email and password
- System returns 201 Created with user object
- System returns 400 Bad Request if email already exists
- System returns 422 Unprocessable Entity if validation fails
For each API endpoint, create test file in tests/api/[feature].spec.ts:
Test Structure (ATDD - Red Phase):
import { test, expect } from '@playwright/test';
// If Playwright Utils enabled:
// import { apiRequest } from '@playwright-utils/api';
test.describe('[Story Name] API Tests (ATDD)', () => {
test.skip('[P0] should register new user successfully', async ({ request }) => {
// THIS TEST WILL FAIL - Endpoint not implemented yet
const response = await request.post('/api/users/register', {
data: {
email: 'newuser@example.com',
password: 'SecurePass123!',
},
});
// Expect 201 but will get 404 (endpoint doesn't exist)
expect(response.status()).toBe(201);
const user = await response.json();
expect(user).toMatchObject({
id: expect.any(Number),
email: 'newuser@example.com',
});
});
test.skip('[P1] should return 400 if email exists', async ({ request }) => {
// THIS TEST WILL FAIL - Endpoint not implemented yet
const response = await request.post('/api/users/register', {
data: {
email: 'existing@example.com',
password: 'SecurePass123!',
},
});
expect(response.status()).toBe(400);
const error = await response.json();
expect(error.message).toContain('Email already exists');
});
});
CRITICAL ATDD Requirements:
test.skip() to mark tests as intentionally failing (red phase)apiRequest() helper if Playwright Utils enabledWhy test.skip():
test.skip() documents this is intentional (TDD red phase)test.skip() to verify green phaseIdentify fixtures needed for API tests:
Do NOT create fixtures yet - just track what's needed for aggregation step.
Write JSON to temp file: /tmp/tea-atdd-api-tests-{{timestamp}}.json
{
"success": true,
"subprocess": "atdd-api-tests",
"tests": [
{
"file": "tests/api/user-registration.spec.ts",
"content": "[full TypeScript test file content with test.skip()]",
"description": "ATDD API tests for user registration (RED PHASE)",
"expected_to_fail": true,
"acceptance_criteria_covered": [
"User can register with email/password",
"System returns 201 on success",
"System returns 400 if email exists"
],
"priority_coverage": {
"P0": 1,
"P1": 2,
"P2": 0,
"P3": 0
}
}
],
"fixture_needs": ["userDataFactory"],
"knowledge_fragments_used": ["api-request", "data-factories", "api-testing-patterns"],
"test_count": 3,
"tdd_phase": "RED",
"summary": "Generated 3 FAILING API tests for user registration story"
}
On Error:
{
"success": false,
"subprocess": "atdd-api-tests",
"error": "Error message describing what went wrong",
"partial_output": {
/* any tests generated before error */
}
}
Subprocess completes when:
test.skip() (documented failing tests)Subprocess terminates here. Parent workflow will read output and proceed to aggregation.