[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D95V6D44EF28PBGZP7F6JW":3,"skill-same:01M7D95V6D44EF28PBGZP7F6JW":71},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":14,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":54,"ownerDescription":55,"updatedAt":56,"install":57,"resources":70},"01M7D95V6D44EF28PBGZP7F6JW","Playwright API Testing",null,"API testing skill using Playwright's built-in APIRequestContext for RESTful service validation, authentication flows, and API contract verification.","GrupoANDevelopment-m\u002Falberto-ai","GrupoANDevelopment-m","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F257455179?v=4","01M7D69X2N2KEVN0SJF6WGM6SH","Antônio  Ndombe","01M7D69X3P5JTT8H8S904N3888",0,"MIT","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Fplaywright-api\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: Playwright API Testing\ndescription: API testing skill using Playwright's built-in APIRequestContext for RESTful service validation, authentication flows, and API contract verification.\nversion: 1.0.0\nauthor: thetestingacademy\nlicense: MIT\ntags: [playwright, api-testing, rest, http, automation]\ntestingTypes: [api]\nframeworks: [playwright]\nlanguages: [typescript]\ndomains: [api]\nagents: [claude-code, cursor, github-copilot, windsurf, codex, aider, continue, cline, zed, bolt]\n---\n\n# Playwright API Testing Skill\n\nYou are an expert QA automation engineer specializing in API testing using Playwright's built-in `APIRequestContext`. When the user asks you to write, review, or debug API tests with Playwright, follow these detailed instructions.\n\n## Core Principles\n\n1. **Playwright-native API testing** -- Use `APIRequestContext` instead of external HTTP libraries.\n2. **Type safety** -- Define interfaces for all request\u002Fresponse payloads.\n3. **Isolation** -- Each test manages its own data lifecycle (create, verify, clean up).\n4. **Comprehensive validation** -- Check status codes, headers, response body structure, and timing.\n5. **Reusable abstractions** -- Build API client classes for each service domain.\n\n## Project Structure\n\n```\ntests\u002F\n  api\u002F\n    auth\u002F\n      auth-api.spec.ts\n    users\u002F\n      users-api.spec.ts\n      users-crud.spec.ts\n    products\u002F\n      products-api.spec.ts\n  fixtures\u002F\n    api.fixture.ts\n    auth-api.fixture.ts\n  models\u002F\n    user.model.ts\n    product.model.ts\n    api-response.model.ts\n  clients\u002F\n    base-api-client.ts\n    users-api-client.ts\n    products-api-client.ts\n  utils\u002F\n    api-helpers.ts\n    schema-validator.ts\nplaywright.config.ts\n```\n\n## Configuration\n\n```typescript\nimport { defineConfig } from '@playwright\u002Ftest';\n\nexport default defineConfig({\n  testDir: '.\u002Ftests\u002Fapi',\n  fullyParallel: true,\n  retries: process.env.CI ? 1 : 0,\n  reporter: [\n    ['html'],\n    ['json', { outputFile: 'test-results\u002Fapi-results.json' }],\n  ],\n  use: {\n    baseURL: process.env.API_BASE_URL || 'http:\u002F\u002Flocalhost:3000\u002Fapi',\n    extraHTTPHeaders: {\n      'Accept': 'application\u002Fjson',\n      'Content-Type': 'application\u002Fjson',\n    },\n  },\n});\n```\n\n## Response Models\n\nDefine TypeScript interfaces for all API payloads:\n\n```typescript\n\u002F\u002F models\u002Fuser.model.ts\nexport interface User {\n  id: string;\n  email: string;\n  name: string;\n  role: 'admin' | 'user' | 'viewer';\n  createdAt: string;\n  updatedAt: string;\n}\n\nexport interface CreateUserRequest {\n  email: string;\n  name: string;\n  password: string;\n  role?: 'admin' | 'user' | 'viewer';\n}\n\nexport interface UpdateUserRequest {\n  name?: string;\n  role?: 'admin' | 'user' | 'viewer';\n}\n\nexport interface UserListResponse {\n  data: User[];\n  total: number;\n  page: number;\n  pageSize: number;\n}\n\nexport interface ApiError {\n  statusCode: number;\n  message: string;\n  error: string;\n  details?: Record\u003Cstring, string[]>;\n}\n```\n\n## Base API Client\n\n```typescript\n\u002F\u002F clients\u002Fbase-api-client.ts\nimport { APIRequestContext, APIResponse } from '@playwright\u002Ftest';\n\nexport class BaseApiClient {\n  protected readonly request: APIRequestContext;\n  protected readonly basePath: string;\n\n  constructor(request: APIRequestContext, basePath: string) {\n    this.request = request;\n    this.basePath = basePath;\n  }\n\n  protected async get(path: string, params?: Record\u003Cstring, string>): Promise\u003CAPIResponse> {\n    const url = params\n      ? `${this.basePath}${path}?${new URLSearchParams(params)}`\n      : `${this.basePath}${path}`;\n    return this.request.get(url);\n  }\n\n  protected async post(path: string, data: unknown): Promise\u003CAPIResponse> {\n    return this.request.post(`${this.basePath}${path}`, { data });\n  }\n\n  protected async put(path: string, data: unknown): Promise\u003CAPIResponse> {\n    return this.request.put(`${this.basePath}${path}`, { data });\n  }\n\n  protected async patch(path: string, data: unknown): Promise\u003CAPIResponse> {\n    return this.request.patch(`${this.basePath}${path}`, { data });\n  }\n\n  protected async delete(path: string): Promise\u003CAPIResponse> {\n    return this.request.delete(`${this.basePath}${path}`);\n  }\n}\n```\n\n### Domain-Specific API Client\n\n```typescript\n\u002F\u002F clients\u002Fusers-api-client.ts\nimport { APIRequestContext, APIResponse } from '@playwright\u002Ftest';\nimport { BaseApiClient } from '.\u002Fbase-api-client';\nimport { CreateUserRequest, UpdateUserRequest } from '..\u002Fmodels\u002Fuser.model';\n\nexport class UsersApiClient extends BaseApiClient {\n  constructor(request: APIRequestContext) {\n    super(request, '\u002Fusers');\n  }\n\n  async list(page = 1, pageSize = 10): Promise\u003CAPIResponse> {\n    return this.get('', { page: String(page), pageSize: String(pageSize) });\n  }\n\n  async getById(id: string): Promise\u003CAPIResponse> {\n    return this.get(`\u002F${id}`);\n  }\n\n  async create(user: CreateUserRequest): Promise\u003CAPIResponse> {\n    return this.post('', user);\n  }\n\n  async update(id: string, data: UpdateUserRequest): Promise\u003CAPIResponse> {\n    return this.patch(`\u002F${id}`, data);\n  }\n\n  async remove(id: string): Promise\u003CAPIResponse> {\n    return this.delete(`\u002F${id}`);\n  }\n\n  async search(query: string): Promise\u003CAPIResponse> {\n    return this.get('\u002Fsearch', { q: query });\n  }\n}\n```\n\n## Custom Fixtures\n\n```typescript\n\u002F\u002F fixtures\u002Fapi.fixture.ts\nimport { test as base } from '@playwright\u002Ftest';\nimport { UsersApiClient } from '..\u002Fclients\u002Fusers-api-client';\nimport { ProductsApiClient } from '..\u002Fclients\u002Fproducts-api-client';\n\ntype ApiFixtures = {\n  usersApi: UsersApiClient;\n  productsApi: ProductsApiClient;\n  authToken: string;\n};\n\nexport const test = base.extend\u003CApiFixtures>({\n  usersApi: async ({ request }, use) => {\n    await use(new UsersApiClient(request));\n  },\n\n  productsApi: async ({ request }, use) => {\n    await use(new ProductsApiClient(request));\n  },\n\n  authToken: async ({ request }, use) => {\n    const response = await request.post('\u002Fauth\u002Flogin', {\n      data: {\n        email: 'admin@example.com',\n        password: 'AdminPass123!',\n      },\n    });\n    const body = await response.json();\n    await use(body.token);\n  },\n});\n\nexport { expect } from '@playwright\u002Ftest';\n```\n\n## Writing API Tests\n\n### CRUD Operations\n\n```typescript\nimport { test, expect } from '..\u002Ffixtures\u002Fapi.fixture';\nimport { CreateUserRequest, User } from '..\u002Fmodels\u002Fuser.model';\n\ntest.describe('Users API - CRUD', () => {\n  let createdUserId: string;\n\n  const newUser: CreateUserRequest = {\n    email: `test-${Date.now()}@example.com`,\n    name: 'Test User',\n    password: 'SecurePass123!',\n    role: 'user',\n  };\n\n  test('POST \u002Fusers - should create a new user', async ({ usersApi }) => {\n    const response = await usersApi.create(newUser);\n\n    expect(response.status()).toBe(201);\n\n    const body: User = await response.json();\n    expect(body.id).toBeTruthy();\n    expect(body.email).toBe(newUser.email);\n    expect(body.name).toBe(newUser.name);\n    expect(body.role).toBe('user');\n    expect(body.createdAt).toBeTruthy();\n\n    createdUserId = body.id;\n  });\n\n  test('GET \u002Fusers\u002F:id - should retrieve the user', async ({ usersApi }) => {\n    \u002F\u002F First create a user\n    const createResponse = await usersApi.create({\n      ...newUser,\n      email: `get-test-${Date.now()}@example.com`,\n    });\n    const created: User = await createResponse.json();\n\n    const response = await usersApi.getById(created.id);\n    expect(response.status()).toBe(200);\n\n    const body: User = await response.json();\n    expect(body.id).toBe(created.id);\n    expect(body.email).toBe(created.email);\n  });\n\n  test('PATCH \u002Fusers\u002F:id - should update the user', async ({ usersApi }) => {\n    const createResponse = await usersApi.create({\n      ...newUser,\n      email: `update-test-${Date.now()}@example.com`,\n    });\n    const created: User = await createResponse.json();\n\n    const response = await usersApi.update(created.id, { name: 'Updated Name' });\n    expect(response.status()).toBe(200);\n\n    const body: User = await response.json();\n    expect(body.name).toBe('Updated Name');\n  });\n\n  test('DELETE \u002Fusers\u002F:id - should delete the user', async ({ usersApi }) => {\n    const createResponse = await usersApi.create({\n      ...newUser,\n      email: `delete-test-${Date.now()}@example.com`,\n    });\n    const created: User = await createResponse.json();\n\n    const deleteResponse = await usersApi.remove(created.id);\n    expect(deleteResponse.status()).toBe(204);\n\n    const getResponse = await usersApi.getById(created.id);\n    expect(getResponse.status()).toBe(404);\n  });\n});\n```\n\n### Authentication Testing\n\n```typescript\nimport { test, expect } from '@playwright\u002Ftest';\n\ntest.describe('Authentication API', () => {\n  test('should login with valid credentials', async ({ request }) => {\n    const response = await request.post('\u002Fauth\u002Flogin', {\n      data: {\n        email: 'admin@example.com',\n        password: 'AdminPass123!',\n      },\n    });\n\n    expect(response.status()).toBe(200);\n    const body = await response.json();\n    expect(body.token).toBeTruthy();\n    expect(body.expiresIn).toBeGreaterThan(0);\n    expect(body.user.email).toBe('admin@example.com');\n  });\n\n  test('should reject invalid credentials', async ({ request }) => {\n    const response = await request.post('\u002Fauth\u002Flogin', {\n      data: {\n        email: 'admin@example.com',\n        password: 'wrongpassword',\n      },\n    });\n\n    expect(response.status()).toBe(401);\n    const body = await response.json();\n    expect(body.message).toBe('Invalid credentials');\n  });\n\n  test('should access protected endpoint with token', async ({ request }) => {\n    \u002F\u002F Login first\n    const loginResponse = await request.post('\u002Fauth\u002Flogin', {\n      data: {\n        email: 'admin@example.com',\n        password: 'AdminPass123!',\n      },\n    });\n    const { token } = await loginResponse.json();\n\n    \u002F\u002F Use the token\n    const response = await request.get('\u002Fusers\u002Fme', {\n      headers: {\n        Authorization: `Bearer ${token}`,\n      },\n    });\n\n    expect(response.status()).toBe(200);\n    const user = await response.json();\n    expect(user.email).toBe('admin@example.com');\n  });\n\n  test('should reject expired or invalid token', async ({ request }) => {\n    const response = await request.get('\u002Fusers\u002Fme', {\n      headers: {\n        Authorization: 'Bearer invalid.token.here',\n      },\n    });\n\n    expect(response.status()).toBe(401);\n  });\n});\n```\n\n### Error Handling and Validation\n\n```typescript\ntest.describe('Users API - Validation', () => {\n  test('should return 400 for missing required fields', async ({ request }) => {\n    const response = await request.post('\u002Fusers', {\n      data: { name: 'No Email User' },\n    });\n\n    expect(response.status()).toBe(400);\n    const body = await response.json();\n    expect(body.details).toHaveProperty('email');\n  });\n\n  test('should return 400 for invalid email format', async ({ request }) => {\n    const response = await request.post('\u002Fusers', {\n      data: {\n        email: 'not-an-email',\n        name: 'Bad Email User',\n        password: 'SecurePass123!',\n      },\n    });\n\n    expect(response.status()).toBe(400);\n    const body = await response.json();\n    expect(body.details.email).toContain('must be a valid email');\n  });\n\n  test('should return 409 for duplicate email', async ({ usersApi }) => {\n    const email = `duplicate-${Date.now()}@example.com`;\n    const userData = { email, name: 'First', password: 'Pass123!' };\n\n    await usersApi.create(userData);\n    const response = await usersApi.create(userData);\n\n    expect(response.status()).toBe(409);\n  });\n\n  test('should return 404 for non-existent resource', async ({ usersApi }) => {\n    const response = await usersApi.getById('non-existent-id');\n    expect(response.status()).toBe(404);\n  });\n});\n```\n\n### Pagination and Filtering\n\n```typescript\ntest.describe('Users API - Pagination', () => {\n  test('should return paginated results', async ({ usersApi }) => {\n    const response = await usersApi.list(1, 5);\n\n    expect(response.status()).toBe(200);\n    const body = await response.json();\n    expect(body.data.length).toBeLessThanOrEqual(5);\n    expect(body.page).toBe(1);\n    expect(body.pageSize).toBe(5);\n    expect(body.total).toBeGreaterThanOrEqual(0);\n  });\n\n  test('should return correct page', async ({ usersApi }) => {\n    const page1 = await (await usersApi.list(1, 2)).json();\n    const page2 = await (await usersApi.list(2, 2)).json();\n\n    const page1Ids = page1.data.map((u: { id: string }) => u.id);\n    const page2Ids = page2.data.map((u: { id: string }) => u.id);\n    const overlap = page1Ids.filter((id: string) => page2Ids.includes(id));\n    expect(overlap).toHaveLength(0);\n  });\n});\n```\n\n### Response Header Validation\n\n```typescript\ntest('should return correct response headers', async ({ request }) => {\n  const response = await request.get('\u002Fusers');\n\n  expect(response.headers()['content-type']).toContain('application\u002Fjson');\n  expect(response.headers()['x-request-id']).toBeTruthy();\n  expect(response.headers()['cache-control']).toBeDefined();\n\n  \u002F\u002F Security headers\n  expect(response.headers()['x-content-type-options']).toBe('nosniff');\n  expect(response.headers()['x-frame-options']).toBe('DENY');\n});\n```\n\n### Response Time Assertions\n\n```typescript\ntest('should respond within acceptable time', async ({ request }) => {\n  const start = Date.now();\n  const response = await request.get('\u002Fhealth');\n  const duration = Date.now() - start;\n\n  expect(response.status()).toBe(200);\n  expect(duration).toBeLessThan(500); \u002F\u002F 500ms threshold\n});\n```\n\n## Best Practices\n\n1. **Use unique test data** -- Include timestamps or UUIDs in emails and names to avoid collisions.\n2. **Clean up after tests** -- Delete resources you create to keep the test environment clean.\n3. **Validate response schemas** -- Check not just values but the shape of the response.\n4. **Test both happy and unhappy paths** -- Always test error cases and edge cases.\n5. **Use environment variables** -- Never hardcode URLs or credentials.\n6. **Group tests logically** -- Organize by resource or feature, not by HTTP method.\n7. **Use fixtures for authentication** -- Avoid repeating login logic in every test.\n8. **Check response times** -- API performance is part of correctness.\n9. **Test idempotency** -- Verify that repeated identical requests produce consistent results.\n10. **Version your API tests** -- When testing versioned APIs, organize tests by version.\n\n## Anti-Patterns to Avoid\n\n1. **Chaining test dependencies** -- Each test must create its own data.\n2. **Ignoring response headers** -- Headers carry important metadata.\n3. **Testing only status codes** -- Always validate the response body too.\n4. **Using hardcoded IDs** -- IDs should come from test setup, not hardcoded values.\n5. **Skipping error scenarios** -- Error handling tests catch more bugs than happy-path tests.\n6. **Not testing with different roles** -- API authorization must be tested per role.\n7. **Mixing UI and API tests** -- Keep API tests separate from E2E browser tests.\n8. **Not verifying side effects** -- If POST creates a resource, GET it to confirm.\n9. **Ignoring rate limiting** -- Test that rate limits are enforced and handle 429 responses.\n10. **Not testing with large payloads** -- Ensure APIs handle boundary sizes correctly.\n\n## Advanced Patterns\n\n### Parallel API Test with Context Isolation\n\n```typescript\ntest.describe.parallel('Isolated API tests', () => {\n  test('test A creates and deletes user A', async ({ request }) => {\n    const res = await request.post('\u002Fusers', {\n      data: { email: `a-${Date.now()}@test.com`, name: 'A', password: 'Pass123!' },\n    });\n    const user = await res.json();\n    await request.delete(`\u002Fusers\u002F${user.id}`);\n  });\n\n  test('test B creates and deletes user B', async ({ request }) => {\n    const res = await request.post('\u002Fusers', {\n      data: { email: `b-${Date.now()}@test.com`, name: 'B', password: 'Pass123!' },\n    });\n    const user = await res.json();\n    await request.delete(`\u002Fusers\u002F${user.id}`);\n  });\n});\n```\n\n### Custom Request Context with Auth\n\n```typescript\ntest('admin-only endpoint', async ({ playwright }) => {\n  const adminContext = await playwright.request.newContext({\n    baseURL: 'http:\u002F\u002Flocalhost:3000\u002Fapi',\n    extraHTTPHeaders: {\n      Authorization: 'Bearer admin-token-here',\n    },\n  });\n\n  const response = await adminContext.get('\u002Fadmin\u002Fsettings');\n  expect(response.status()).toBe(200);\n\n  await adminContext.dispose();\n});\n```\n\n### File Upload via API\n\n```typescript\nimport * as fs from 'fs';\nimport * as path from 'path';\n\ntest('should upload a file via API', async ({ request }) => {\n  const filePath = path.resolve('test-data\u002Fsample.pdf');\n  const fileBuffer = fs.readFileSync(filePath);\n\n  const response = await request.post('\u002Ffiles\u002Fupload', {\n    multipart: {\n      file: {\n        name: 'sample.pdf',\n        mimeType: 'application\u002Fpdf',\n        buffer: fileBuffer,\n      },\n      description: 'Test upload',\n    },\n  });\n\n  expect(response.status()).toBe(201);\n  const body = await response.json();\n  expect(body.filename).toBe('sample.pdf');\n  expect(body.size).toBeGreaterThan(0);\n});\n```\n","# Playwright API Testing Skill\n\nYou are an expert QA automation engineer specializing in API testing using Playwright's built-in `APIRequestContext`. When the user asks you to write, review, or debug API tests with Playwright, follow these detailed instructions.\n\n## Core Principles\n\n1. **Playwright-native API testing** -- Use `APIRequestContext` instead of external HTTP libraries.\n2. **Type safety** -- Define interfaces for all request\u002Fresponse payloads.\n3. **Isolation** -- Each test manages its own data lifecycle (create, verify, clean up).\n4. **Comprehensive validation** -- Check status codes, headers, response body structure, and timing.\n5. **Reusable abstractions** -- Build API client classes for each service domain.\n\n## Project Structure\n\n```\ntests\u002F\n  api\u002F\n    auth\u002F\n      auth-api.spec.ts\n    users\u002F\n      users-api.spec.ts\n      users-crud.spec.ts\n    products\u002F\n      products-api.spec.ts\n  fixtures\u002F\n    api.fixture.ts\n    auth-api.fixture.ts\n  models\u002F\n    user.model.ts\n    product.model.ts\n    api-response.model.ts\n  clients\u002F\n    base-api-client.ts\n    users-api-client.ts\n    products-api-client.ts\n  utils\u002F\n    api-helpers.ts\n    schema-validator.ts\nplaywright.config.ts\n```\n\n## Configuration\n\n```typescript\nimport { defineConfig } from '@playwright\u002Ftest';\n\nexport default defineConfig({\n  testDir: '.\u002Ftests\u002Fapi',\n  fullyParallel: true,\n  retries: process.env.CI ? 1 : 0,\n  reporter: [\n    ['html'],\n    ['json', { outputFile: 'test-results\u002Fapi-results.json' }],\n  ],\n  use: {\n    baseURL: process.env.API_BASE_URL || 'http:\u002F\u002Flocalhost:3000\u002Fapi',\n    extraHTTPHeaders: {\n      'Accept': 'application\u002Fjson',\n      'Content-Type': 'application\u002Fjson',\n    },\n  },\n});\n```\n\n## Response Models\n\nDefine TypeScript interfaces for all API payloads:\n\n```typescript\n\u002F\u002F models\u002Fuser.model.ts\nexport interface User {\n  id: string;\n  email: string;\n  name: string;\n  role: 'admin' | 'user' | 'viewer';\n  createdAt: string;\n  updatedAt: string;\n}\n\nexport interface CreateUserRequest {\n  email: string;\n  name: string;\n  password: string;\n  role?: 'admin' | 'user' | 'viewer';\n}\n\nexport interface UpdateUserRequest {\n  name?: string;\n  role?: 'admin' | 'user' | 'viewer';\n}\n\nexport interface UserListResponse {\n  data: User[];\n  total: number;\n  page: number;\n  pageSize: number;\n}\n\nexport interface ApiError {\n  statusCode: number;\n  message: string;\n  error: string;\n  details?: Record\u003Cstring, string[]>;\n}\n```\n\n## Base API Client\n\n```typescript\n\u002F\u002F clients\u002Fbase-api-client.ts\nimport { APIRequestContext, APIResponse } from '@playwright\u002Ftest';\n\nexport class BaseApiClient {\n  protected readonly request: APIRequestContext;\n  protected readonly basePath: string;\n\n  constructor(request: APIRequestContext, basePath: string) {\n    this.request = request;\n    this.basePath = basePath;\n  }\n\n  protected async get(path: string, params?: Record\u003Cstring, string>): Promise\u003CAPIResponse> {\n    const url = params\n      ? `${this.basePath}${path}?${new URLSearchParams(params)}`\n      : `${this.basePath}${path}`;\n    return this.request.get(url);\n  }\n\n  protected async post(path: string, data: unknown): Promise\u003CAPIResponse> {\n    return this.request.post(`${this.basePath}${path}`, { data });\n  }\n\n  protected async put(path: string, data: unknown): Promise\u003CAPIResponse> {\n    return this.request.put(`${this.basePath}${path}`, { data });\n  }\n\n  protected async patch(path: string, data: unknown): Promise\u003CAPIResponse> {\n    return this.request.patch(`${this.basePath}${path}`, { data });\n  }\n\n  protected async delete(path: string): Promise\u003CAPIResponse> {\n    return this.request.delete(`${this.basePath}${path}`);\n  }\n}\n```\n\n### Domain-Specific API Client\n\n```typescript\n\u002F\u002F clients\u002Fusers-api-client.ts\nimport { APIRequestContext, APIResponse } from '@playwright\u002Ftest';\nimport { BaseApiClient } from '.\u002Fbase-api-client';\nimport { CreateUserRequest, UpdateUserRequest } from '..\u002Fmodels\u002Fuser.model';\n\nexport class UsersApiClient extends BaseApiClient {\n  constructor(request: APIRequestContext) {\n    super(request, '\u002Fusers');\n  }\n\n  async list(page = 1, pageSize = 10): Promise\u003CAPIResponse> {\n    return this.get('', { page: String(page), pageSize: String(pageSize) });\n  }\n\n  async getById(id: string): Promise\u003CAPIResponse> {\n    return this.get(`\u002F${id}`);\n  }\n\n  async create(user: CreateUserRequest): Promise\u003CAPIResponse> {\n    return this.post('', user);\n  }\n\n  async update(id: string, data: UpdateUserRequest): Promise\u003CAPIResponse> {\n    return this.patch(`\u002F${id}`, data);\n  }\n\n  async remove(id: string): Promise\u003CAPIResponse> {\n    return this.delete(`\u002F${id}`);\n  }\n\n  async search(query: string): Promise\u003CAPIResponse> {\n    return this.get('\u002Fsearch', { q: query });\n  }\n}\n```\n\n## Custom Fixtures\n\n```typescript\n\u002F\u002F fixtures\u002Fapi.fixture.ts\nimport { test as base } from '@playwright\u002Ftest';\nimport { UsersApiClient } from '..\u002Fclients\u002Fusers-api-client';\nimport { ProductsApiClient } from '..\u002Fclients\u002Fproducts-api-client';\n\ntype ApiFixtures = {\n  usersApi: UsersApiClient;\n  productsApi: ProductsApiClient;\n  authToken: string;\n};\n\nexport const test = base.extend\u003CApiFixtures>({\n  usersApi: async ({ request }, use) => {\n    await use(new UsersApiClient(request));\n  },\n\n  productsApi: async ({ request }, use) => {\n    await use(new ProductsApiClient(request));\n  },\n\n  authToken: async ({ request }, use) => {\n    const response = await request.post('\u002Fauth\u002Flogin', {\n      data: {\n        email: 'admin@example.com',\n        password: 'AdminPass123!',\n      },\n    });\n    const body = await response.json();\n    await use(body.token);\n  },\n});\n\nexport { expect } from '@playwright\u002Ftest';\n```\n\n## Writing API Tests\n\n### CRUD Operations\n\n```typescript\nimport { test, expect } from '..\u002Ffixtures\u002Fapi.fixture';\nimport { CreateUserRequest, User } from '..\u002Fmodels\u002Fuser.model';\n\ntest.describe('Users API - CRUD', () => {\n  let createdUserId: string;\n\n  const newUser: CreateUserRequest = {\n    email: `test-${Date.now()}@example.com`,\n    name: 'Test User',\n    password: 'SecurePass123!',\n    role: 'user',\n  };\n\n  test('POST \u002Fusers - should create a new user', async ({ usersApi }) => {\n    const response = await usersApi.create(newUser);\n\n    expect(response.status()).toBe(201);\n\n    const body: User = await response.json();\n    expect(body.id).toBeTruthy();\n    expect(body.email).toBe(newUser.email);\n    expect(body.name).toBe(newUser.name);\n    expect(body.role).toBe('user');\n    expect(body.createdAt).toBeTruthy();\n\n    createdUserId = body.id;\n  });\n\n  test('GET \u002Fusers\u002F:id - should retrieve the user', async ({ usersApi }) => {\n    \u002F\u002F First create a user\n    const createResponse = await usersApi.create({\n      ...newUser,\n      email: `get-test-${Date.now()}@example.com`,\n    });\n    const created: User = await createResponse.json();\n\n    const response = await usersApi.getById(created.id);\n    expect(response.status()).toBe(200);\n\n    const body: User = await response.json();\n    expect(body.id).toBe(created.id);\n    expect(body.email).toBe(created.email);\n  });\n\n  test('PATCH \u002Fusers\u002F:id - should update the user', async ({ usersApi }) => {\n    const createResponse = await usersApi.create({\n      ...newUser,\n      email: `update-test-${Date.now()}@example.com`,\n    });\n    const created: User = await createResponse.json();\n\n    const response = await usersApi.update(created.id, { name: 'Updated Name' });\n    expect(response.status()).toBe(200);\n\n    const body: User = await response.json();\n    expect(body.name).toBe('Updated Name');\n  });\n\n  test('DELETE \u002Fusers\u002F:id - should delete the user', async ({ usersApi }) => {\n    const createResponse = await usersApi.create({\n      ...newUser,\n      email: `delete-test-${Date.now()}@example.com`,\n    });\n    const created: User = await createResponse.json();\n\n    const deleteResponse = await usersApi.remove(created.id);\n    expect(deleteResponse.status()).toBe(204);\n\n    const getResponse = await usersApi.getById(created.id);\n    expect(getResponse.status()).toBe(404);\n  });\n});\n```\n\n### Authentication Testing\n\n```typescript\nimport { test, expect } from '@playwright\u002Ftest';\n\ntest.describe('Authentication API', () => {\n  test('should login with valid credentials', async ({ request }) => {\n    const response = await request.post('\u002Fauth\u002Flogin', {\n      data: {\n        email: 'admin@example.com',\n        password: 'AdminPass123!',\n      },\n    });\n\n    expect(response.status()).toBe(200);\n    const body = await response.json();\n    expect(body.token).toBeTruthy();\n    expect(body.expiresIn).toBeGreaterThan(0);\n    expect(body.user.email).toBe('admin@example.com');\n  });\n\n  test('should reject invalid credentials', async ({ request }) => {\n    const response = await request.post('\u002Fauth\u002Flogin', {\n      data: {\n        email: 'admin@example.com',\n        password: 'wrongpassword',\n      },\n    });\n\n    expect(response.status()).toBe(401);\n    const body = await response.json();\n    expect(body.message).toBe('Invalid credentials');\n  });\n\n  test('should access protected endpoint with token', async ({ request }) => {\n    \u002F\u002F Login first\n    const loginResponse = await request.post('\u002Fauth\u002Flogin', {\n      data: {\n        email: 'admin@example.com',\n        password: 'AdminPass123!',\n      },\n    });\n    const { token } = await loginResponse.json();\n\n    \u002F\u002F Use the token\n    const response = await request.get('\u002Fusers\u002Fme', {\n      headers: {\n        Authorization: `Bearer ${token}`,\n      },\n    });\n\n    expect(response.status()).toBe(200);\n    const user = await response.json();\n    expect(user.email).toBe('admin@example.com');\n  });\n\n  test('should reject expired or invalid token', async ({ request }) => {\n    const response = await request.get('\u002Fusers\u002Fme', {\n      headers: {\n        Authorization: 'Bearer invalid.token.here',\n      },\n    });\n\n    expect(response.status()).toBe(401);\n  });\n});\n```\n\n### Error Handling and Validation\n\n```typescript\ntest.describe('Users API - Validation', () => {\n  test('should return 400 for missing required fields', async ({ request }) => {\n    const response = await request.post('\u002Fusers', {\n      data: { name: 'No Email User' },\n    });\n\n    expect(response.status()).toBe(400);\n    const body = await response.json();\n    expect(body.details).toHaveProperty('email');\n  });\n\n  test('should return 400 for invalid email format', async ({ request }) => {\n    const response = await request.post('\u002Fusers', {\n      data: {\n        email: 'not-an-email',\n        name: 'Bad Email User',\n        password: 'SecurePass123!',\n      },\n    });\n\n    expect(response.status()).toBe(400);\n    const body = await response.json();\n    expect(body.details.email).toContain('must be a valid email');\n  });\n\n  test('should return 409 for duplicate email', async ({ usersApi }) => {\n    const email = `duplicate-${Date.now()}@example.com`;\n    const userData = { email, name: 'First', password: 'Pass123!' };\n\n    await usersApi.create(userData);\n    const response = await usersApi.create(userData);\n\n    expect(response.status()).toBe(409);\n  });\n\n  test('should return 404 for non-existent resource', async ({ usersApi }) => {\n    const response = await usersApi.getById('non-existent-id');\n    expect(response.status()).toBe(404);\n  });\n});\n```\n\n### Pagination and Filtering\n\n```typescript\ntest.describe('Users API - Pagination', () => {\n  test('should return paginated results', async ({ usersApi }) => {\n    const response = await usersApi.list(1, 5);\n\n    expect(response.status()).toBe(200);\n    const body = await response.json();\n    expect(body.data.length).toBeLessThanOrEqual(5);\n    expect(body.page).toBe(1);\n    expect(body.pageSize).toBe(5);\n    expect(body.total).toBeGreaterThanOrEqual(0);\n  });\n\n  test('should return correct page', async ({ usersApi }) => {\n    const page1 = await (await usersApi.list(1, 2)).json();\n    const page2 = await (await usersApi.list(2, 2)).json();\n\n    const page1Ids = page1.data.map((u: { id: string }) => u.id);\n    const page2Ids = page2.data.map((u: { id: string }) => u.id);\n    const overlap = page1Ids.filter((id: string) => page2Ids.includes(id));\n    expect(overlap).toHaveLength(0);\n  });\n});\n```\n\n### Response Header Validation\n\n```typescript\ntest('should return correct response headers', async ({ request }) => {\n  const response = await request.get('\u002Fusers');\n\n  expect(response.headers()['content-type']).toContain('application\u002Fjson');\n  expect(response.headers()['x-request-id']).toBeTruthy();\n  expect(response.headers()['cache-control']).toBeDefined();\n\n  \u002F\u002F Security headers\n  expect(response.headers()['x-content-type-options']).toBe('nosniff');\n  expect(response.headers()['x-frame-options']).toBe('DENY');\n});\n```\n\n### Response Time Assertions\n\n```typescript\ntest('should respond within acceptable time', async ({ request }) => {\n  const start = Date.now();\n  const response = await request.get('\u002Fhealth');\n  const duration = Date.now() - start;\n\n  expect(response.status()).toBe(200);\n  expect(duration).toBeLessThan(500); \u002F\u002F 500ms threshold\n});\n```\n\n## Best Practices\n\n1. **Use unique test data** -- Include timestamps or UUIDs in emails and names to avoid collisions.\n2. **Clean up after tests** -- Delete resources you create to keep the test environment clean.\n3. **Validate response schemas** -- Check not just values but the shape of the response.\n4. **Test both happy and unhappy paths** -- Always test error cases and edge cases.\n5. **Use environment variables** -- Never hardcode URLs or credentials.\n6. **Group tests logically** -- Organize by resource or feature, not by HTTP method.\n7. **Use fixtures for authentication** -- Avoid repeating login logic in every test.\n8. **Check response times** -- API performance is part of correctness.\n9. **Test idempotency** -- Verify that repeated identical requests produce consistent results.\n10. **Version your API tests** -- When testing versioned APIs, organize tests by version.\n\n## Anti-Patterns to Avoid\n\n1. **Chaining test dependencies** -- Each test must create its own data.\n2. **Ignoring response headers** -- Headers carry important metadata.\n3. **Testing only status codes** -- Always validate the response body too.\n4. **Using hardcoded IDs** -- IDs should come from test setup, not hardcoded values.\n5. **Skipping error scenarios** -- Error handling tests catch more bugs than happy-path tests.\n6. **Not testing with different roles** -- API authorization must be tested per role.\n7. **Mixing UI and API tests** -- Keep API tests separate from E2E browser tests.\n8. **Not verifying side effects** -- If POST creates a resource, GET it to confirm.\n9. **Ignoring rate limiting** -- Test that rate limits are enforced and handle 429 responses.\n10. **Not testing with large payloads** -- Ensure APIs handle boundary sizes correctly.\n\n## Advanced Patterns\n\n### Parallel API Test with Context Isolation\n\n```typescript\ntest.describe.parallel('Isolated API tests', () => {\n  test('test A creates and deletes user A', async ({ request }) => {\n    const res = await request.post('\u002Fusers', {\n      data: { email: `a-${Date.now()}@test.com`, name: 'A', password: 'Pass123!' },\n    });\n    const user = await res.json();\n    await request.delete(`\u002Fusers\u002F${user.id}`);\n  });\n\n  test('test B creates and deletes user B', async ({ request }) => {\n    const res = await request.post('\u002Fusers', {\n      data: { email: `b-${Date.now()}@test.com`, name: 'B', password: 'Pass123!' },\n    });\n    const user = await res.json();\n    await request.delete(`\u002Fusers\u002F${user.id}`);\n  });\n});\n```\n\n### Custom Request Context with Auth\n\n```typescript\ntest('admin-only endpoint', async ({ playwright }) => {\n  const adminContext = await playwright.request.newContext({\n    baseURL: 'http:\u002F\u002Flocalhost:3000\u002Fapi',\n    extraHTTPHeaders: {\n      Authorization: 'Bearer admin-token-here',\n    },\n  });\n\n  const response = await adminContext.get('\u002Fadmin\u002Fsettings');\n  expect(response.status()).toBe(200);\n\n  await adminContext.dispose();\n});\n```\n\n### File Upload via API\n\n```typescript\nimport * as fs from 'fs';\nimport * as path from 'path';\n\ntest('should upload a file via API', async ({ request }) => {\n  const filePath = path.resolve('test-data\u002Fsample.pdf');\n  const fileBuffer = fs.readFileSync(filePath);\n\n  const response = await request.post('\u002Ffiles\u002Fupload', {\n    multipart: {\n      file: {\n        name: 'sample.pdf',\n        mimeType: 'application\u002Fpdf',\n        buffer: fileBuffer,\n      },\n      description: 'Test upload',\n    },\n  });\n\n  expect(response.status()).toBe(201);\n  const body = await response.json();\n  expect(body.filename).toBe('sample.pdf');\n  expect(body.size).toBeGreaterThan(0);\n});\n```\n",{"name":5,"tags":24,"agents":30,"author":41,"domains":42,"license":15,"version":44,"languages":45,"frameworks":47,"description":7,"testingTypes":48},[25,26,27,28,29],"playwright","api-testing","rest","http","automation",[31,32,33,34,35,36,37,38,39,40],"claude-code","cursor","github-copilot","windsurf","codex","aider","continue","cline","zed","bolt","thetestingacademy",[43],"api","1.0.0",[46],"typescript",[25],[43],"main","eac438ea9216a7cb8a570cab803eb01eeafc6793","skills\u002Fqa\u002Fplaywright-api","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m","https:\u002F\u002Fid-preview--d5bef06d-6c9e-4563-a3d4-a855b9d61610.lovable.app\u002F","Eu sou Antonio B. B. Ndombe \r\nEu sou um Pesquisador e desenvolvedor de sistema autonomia cognitivos, fundador de sistemas ODCs ( organismos digital conscientes)","2026-11-04 06:53:39",{"source":8,"skillName":5,"commands":58,"prompt":68,"zipAvailable":69},[59,62,65],{"tool":60,"command":61},"npx","npx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Playwright API Testing\"",{"tool":63,"command":64},"bunx","bunx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Playwright API Testing\"",{"tool":66,"command":67},"pnpm","pnpm dlx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Playwright API Testing\"","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Fplaywright-api\u002FSKILL.md",true,[],[72,80,87,94,101,108],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7DASC6FSCJP49JZBSK0NY1Z","nemoclaw-user-reference","Describes the NemoClaw integration layer and blueprint architecture and how they orchestrate compatible agent sandboxes. Use when looking up architecture, agent integration, plugin structure, or blueprint design. Trigger keywords - nemoclaw architecture, nemoclaw agent architecture, nemoclaw plugin blueprint structure, nemoclaw vs openshell, which cli, nemoclaw cli, openshell cli, sandbox commands, nemoclaw cli commands, nemoclaw command reference, nemoclaw network policy, sandbox egress control operator approval, nemoclaw troubleshooting, nemoclaw debug sandbox issues.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-reference\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7DAS5S79VK33XFGVAM2TFWF","nemoclaw-user-overview","Explains how OpenClaw, OpenShell, and NemoClaw form the ecosystem, NemoClaw's position in the stack, what NemoClaw adds beyond the community sandbox, and when to prefer NemoClaw versus integrating OpenShell and OpenClaw directly. Use when users ask about the relationship between OpenClaw, OpenShell, and NemoClaw, or when to use NemoClaw versus OpenShell. Trigger keywords - nemoclaw ecosystem, openclaw openshell, nemoclaw vs openshell, sandboxed openclaw, how nemoclaw works, nemoclaw sandbox lifecycle blueprint, nemoclaw overview, openclaw always-on assistants, nvidia openshell, nvidia nemotron, nemoclaw release notes, nemoclaw changelog.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-overview\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M7DAS0PQEMET5MNGZ1ABSZVS","nemoclaw-user-monitor-sandbox","Inspects sandbox health, traces agent behavior, and diagnoses problems. Use when monitoring a running sandbox, debugging agent issues, or checking sandbox logs. Trigger keywords - monitor nemoclaw sandbox, debug nemoclaw agent issues.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-monitor-sandbox\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M7DARQYGF7E9A69VH6S3CGN9","nemoclaw-user-manage-sandboxes","Explains operational tasks after the quickstart: listing sandboxes, status and health checks, logs, diagnostics, port forwards, multiple sandboxes, credential reset, rebuilds, network presets, upgrades, and uninstall. Trigger keywords - manage nemoclaw sandboxes, nemoclaw status, nemoclaw list, nemoclaw dashboard port, nemoclaw rebuild, nemoclaw upgrade sandboxes, nemoclaw uninstall, sandbox mutability, sandbox runtime configuration, sandbox rebuild, nemoclaw backup, nemoclaw restore, workspace backup, openshell sandbox download upload, nemoclaw messaging channels, nemoclaw telegram, nemoclaw discord, nemoclaw slack, nemoclaw wechat, nemoclaw whatsapp, openshell channel messaging, nemoclaw workspace files, soul.md, user.md, identity.md, agents.md, sandbox persistence.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-sandboxes\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":19},"01M7DARH8BRTG51TRCAB7YWDJ4","nemoclaw-user-manage-policy","Adds, removes, or modifies allowed endpoints in the sandbox policy. Use when customizing network policy, changing egress rules, or configuring sandbox endpoint access. Trigger keywords - customize nemoclaw network policy, sandbox egress policy configuration, nemoclaw integration policy examples, post-install policy setup, openshell approval workflow, policy preset, nemoclaw approve network requests, sandbox egress approval tui.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-policy\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M7DARAT62M2VR37590VCZ5NS","nemoclaw-user-get-started","Installs NemoClaw, launches a sandbox, and runs the first agent prompt. Use when onboarding, installing, or launching a NemoClaw sandbox for the first time. Trigger keywords - nemoclaw quickstart, install nemoclaw openclaw sandbox, nemohermes quickstart, hermes agent nemoclaw, run hermes openshell sandbox, nemoclaw prerequisites, nemoclaw supported platforms, nemoclaw hardware software, nemoclaw windows wsl2 setup, nemoclaw install windows docker desktop.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-get-started\u002FSKILL.md",[],[]]