api-playwright-test-developer
БесплатноБез исполняемых скриптовНе проверенWrites and reviews API automation tests with Playwright Test, covering setup/teardown, assertions, data management, and hybrid API+UI flows. Use when creating…
от jaktestowac★ 124 звезды на GitHubОб этом скилле
API Playwright Test Developer
This skill defines the standard approach for writing and maintaining Playwright-based API tests. It is optimized for robust, repeatable automated validation of REST/GraphQL services, readable test design, and minimal flakiness.
When to Use
- API endpoint functional testing (status, schema, body values)
- Data-driven regression coverage across all environments
- Contract checks (OpenAPI/JSON Schema) for service evolution
- End-to-end test flows mixing UI and API interactions (hybrid tests)
- CI pipeline smoke tests and API health checks
Core Principles
- Explicit setup/teardown
- Use
test.beforeEachandtest.afterEachfor consistent test state management (e.g., create/delete test data). - Clean up created test data in
test.afterEachby default. Skip cleanup only temporarily when debugging a failure, and never commit that state. - Avoid shared mutable state across tests to prevent flakiness.
- Use unique identifiers in test data to avoid collisions and ensure idempotency.
- Use
- Single responsibility per test case
- Each test should target one behavior (e.g., 200 vs 401, field validation, paginated listing).
- Use descriptive test titles to clarify the intent and expected outcome.
- For complex scenarios, break down into multiple focused tests rather than one large test with many assertions.
- When testing e2e flows, consider using
test.stepto logically group related API calls and assertions within a single test case.
- Assertions
- Avoid brittle tests that rely on dynamic timestamps or ordering unless controlled.
- Add descriptive messages to assertions for easier debugging.
- Use soft assertions
expect.softfor multiple checks in a single test without stopping at the first failure.
- Clear data management
- Use fixtures/config to store base URL, auth tokens, test payload templates.
- Use factory functions to generate test data with unique identifiers.
- Avoid hardcoding environment-specific values in tests; use environment variables or config files.
- For complex data setup, consider using API calls in
beforeEachto create necessary resources instead of relying on static test data.
- Patterns and best practices
- Use
requestfixture for API calls. - Use AAA pattern (Arrange-Act-Assert) for test structure.
- Use builders or factories for constructing request payloads to improve readability and maintainability.
- Use Simple Request Object Pattern to encapsulate API interactions and reduce duplication across tests.
- Use
test.describeto group related tests and share setup/teardown logic.
- Use
Recommended Folder Layout
.
├── tests/
│ ├── api/
│ │ ├── users.spec.ts
│ │ ├── auth.spec.ts
│ │ ├── orders.spec.ts
│ │ └── contracts.spec.ts
│ ├── e2e/
│ │ ├── signup-and-purchase.spec.ts
│ │ └── checkout-api-ui.spec.ts
│ └── fixtures/
│ ├── api-fixtures.ts
│ ├── data-fixtures.ts
│ └── auth-fixtures.ts
├── helpers/
│ ├── api-helpers.ts
│ ├── schema-validators.ts
│ └── retry-utils.ts
├── data/
│ └── payloads/
│ ├── create-user.json
│ ├── update-order.json
│ └── login.json
├── docs/
│ └── api-test-guidelines.md
├── .github/
│ └── workflows/
│ └── api-tests.yml
├── playwright.config.ts
└── .env.example
tests/api/: dedicated API service tests and contract/spec tests.tests/e2e/: hybrid scenarios that combine UI and API flows.tests/fixtures/: setup data and auth fixtures for Playwright Test.helpers/: reusable request builders, response assertions, schema validators.data/payloads/: canonical test payloads to avoid inline duplication..env.example: environment abstraction for endpoints and tokens..github/workflows/api-tests.yml: CI pipeline orchestration with separate API test job.
Playwright Test Example (TypeScript)
import { test, expect } from '@playwright/test';
test.describe('API: /users', () => {
test('GET /users returns 200 and JSON schema', async ({ request }) => {
const response = await request.get('/api/users', {
headers: { Authorization: `Bearer ${process.env.API_TOKEN}` },
});
expect(response.status()).toBe(200);
expect(response.headers()['content-type']).toContain('application/json');
const body = await response.json();
expect(Array.isArray(body)).toBeTruthy();
expect(body.length).toBeGreaterThanOrEqual(0);
});
});
Common Patterns
request.get,request.post,request.put,request.deleteHTTP retries for transient 5xx responses (in test infrastructure, not per-test)
Data-driven tests: Playwright Test has no
test.each- loop over a test-case array instead, so each case registers as its own test:const cases = [ { name: 'admin', role: 'admin', expectedStatus: 200 }, { name: 'guest', role: 'guest', expectedStatus: 403 }, ]; for (const data of cases) { test(
Установить api-playwright-test-developer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл api-playwright-test-developer?
Writes and reviews API automation tests with Playwright Test, covering setup/teardown, assertions, data management, and hybrid API+UI flows. Use when creating backend API tests, contract checks, data-driven API coverage, API+UI hybrid workflows, or reviewing existing Playwright API suites.
Как установить скилл api-playwright-test-developer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл api-playwright-test-developer запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic