Skip to content

alirezarezvani/claude-skills / engineering-team/playwright-pro/skills/pw

Use for any Playwright or end-to-end browser testing work: writing tests, fixing flaky ones, migrating from Cypress or Selenium, CI setup, TestRail or BrowserStack. Routes to the matching /pw sub-skill and its 55 templates.

FileKindSize
SKILL.mdskill md5.5 KB
reference/assertions.mdmarkdown2.2 KB
reference/common-pitfalls.mdmarkdown3.1 KB
reference/fixtures.mdmarkdown3.1 KB
reference/flaky-tests.mdmarkdown1.5 KB
reference/golden-rules.mdmarkdown906 B
reference/locators.mdmarkdown2.1 KB
templates/README.mdmarkdown4.8 KB
templates/accessibility/color-contrast.mdmarkdown5.5 KB
templates/accessibility/keyboard-navigation.mdmarkdown5.2 KB
templates/accessibility/screen-reader.mdmarkdown5.6 KB
templates/api/auth-headers.mdmarkdown4.7 KB
templates/api/error-responses.mdmarkdown5.4 KB
templates/api/graphql.mdmarkdown5.9 KB
templates/api/rate-limiting.mdmarkdown5.5 KB
templates/api/rest-crud.mdmarkdown5.0 KB
templates/auth/login.mdmarkdown4.6 KB
templates/auth/logout.mdmarkdown4.1 KB
templates/auth/mfa.mdmarkdown5.1 KB
templates/auth/password-reset.mdmarkdown5.7 KB
templates/auth/rbac.mdmarkdown4.7 KB
templates/auth/remember-me.mdmarkdown5.6 KB
templates/auth/session-timeout.mdmarkdown4.3 KB
templates/auth/sso.mdmarkdown4.5 KB
templates/checkout/add-to-cart.mdmarkdown4.1 KB
templates/checkout/apply-coupon.mdmarkdown5.0 KB
templates/checkout/order-confirm.mdmarkdown4.1 KB
templates/checkout/order-history.mdmarkdown4.6 KB
templates/checkout/payment.mdmarkdown5.4 KB
templates/checkout/update-quantity.mdmarkdown4.8 KB
templates/crud/bulk-operations.mdmarkdown5.2 KB
templates/crud/create.mdmarkdown4.7 KB
templates/crud/delete.mdmarkdown5.1 KB
templates/crud/read.mdmarkdown4.6 KB
templates/crud/soft-delete.mdmarkdown4.7 KB
templates/crud/update.mdmarkdown5.6 KB
templates/dashboard/chart-rendering.mdmarkdown4.9 KB
templates/dashboard/data-loading.mdmarkdown4.9 KB
templates/dashboard/date-range-filter.mdmarkdown5.5 KB
templates/dashboard/export.mdmarkdown5.7 KB
templates/dashboard/realtime-updates.mdmarkdown5.1 KB
templates/forms/autosave.mdmarkdown5.3 KB
templates/forms/conditional-fields.mdmarkdown5.6 KB
templates/forms/file-upload.mdmarkdown5.2 KB
templates/forms/multi-step.mdmarkdown5.5 KB
templates/forms/single-step.mdmarkdown4.8 KB
templates/forms/validation.mdmarkdown5.8 KB
templates/notifications/in-app.mdmarkdown4.8 KB
templates/notifications/notification-center.mdmarkdown4.7 KB
templates/notifications/toast-messages.mdmarkdown5.2 KB
templates/onboarding/email-verification.mdmarkdown5.0 KB
templates/onboarding/first-time-setup.mdmarkdown5.3 KB
templates/onboarding/registration.mdmarkdown5.7 KB
templates/onboarding/welcome-tour.mdmarkdown4.8 KB
templates/search/basic-search.mdmarkdown4.4 KB
templates/search/empty-state.mdmarkdown4.5 KB
templates/search/filters.mdmarkdown5.1 KB
templates/search/pagination.mdmarkdown4.4 KB
templates/search/sorting.mdmarkdown5.1 KB
templates/settings/account-delete.mdmarkdown5.7 KB
templates/settings/notification-prefs.mdmarkdown5.2 KB
templates/settings/password-change.mdmarkdown6.9 KB
templates/settings/profile-update.mdmarkdown5.2 KB

templates/api/error-responses.md

View on GitHub
# API Error Responses Template

Tests 400, 401, 403, 404, and 500 HTTP error handling.

## Prerequisites
- Valid auth token: `{{apiToken}}`
- API base: `{{apiBaseUrl}}`

---

## TypeScript

```typescript
import { test, expect } from '@playwright/test';

const validHeaders = {
  'Authorization': `Bearer {{apiToken}}`,
  'Content-Type': 'application/json',
};

test.describe('API Error Responses', () => {
  // 400 Bad Request
  test('POST with invalid body returns 400', async ({ request }) => {
    const res = await request.post('{{apiBaseUrl}}/{{entityName}}s', {
      headers: validHeaders,
      data: { name: '' }, // name too short / blank
    });
    expect(res.status()).toBe(400);
    const body = await res.json();
    expect(body.message ?? body.error).toMatch(/bad request|invalid/i);
    expect(body.errors ?? body.details).toBeDefined();
  });

  // 401 Unauthorized
  test('request without token returns 401', async ({ request }) => {
    const res = await request.get('{{apiBaseUrl}}/{{entityName}}s');
    expect(res.status()).toBe(401);
    const body = await res.json();
    expect(body.message ?? body.error).toMatch(/unauthorized|authentication/i);
  });

  // 403 Forbidden
  test('accessing admin endpoint as regular user returns 403', async ({ request }) => {
    const res = await request.get('{{apiBaseUrl}}/admin/users', {
      headers: { 'Authorization': `Bearer {{userToken}}` },
    });
    expect(res.status()).toBe(403);
    const body = await res.json();
    expect(body.message ?? body.error).toMatch(/forbidden|insufficient.*permission/i);
  });

  // 404 Not Found
  test('GET non-existent resource returns 404', async ({ request }) => {
    const res = await request.get('{{apiBaseUrl}}/{{entityName}}s/999999', { headers: validHeaders });
    expect(res.status()).toBe(404);
    const body = await res.json();
    expect(body.message ?? body.error).toMatch(/not found/i);
  });

  // 422 Unprocessable Entity
  test('POST with missing required field returns 422', async ({ request }) => {
    const res = await request.post('{{apiBaseUrl}}/{{entityName}}s', {
      headers: validHeaders,
      data: { description: 'no name provided' },
    });
    expect([422, 400]).toContain(res.status());
    const body = await res.json();
    expect(body.errors ?? body.details).toBeDefined();
  });

  // 429 Too Many Requests (handled in rate-limiting template — kept here for completeness)
  test('returns 429 when rate limit exceeded', async ({ request }) => {
    let lastStatus = 0;
    for (let i = 0; i < {{rateLimitThreshold}} + 1; i++) {
      const res = await request.get('{{apiBaseUrl}}/{{rateLimitedEndpoint}}', { headers: validHeaders });
      lastStatus = res.status();
      if (lastStatus === 429) break;
    }
    expect(lastStatus).toBe(429);
  });

  // 500 Internal Server Error
  test('server error returns 500 with error body', async ({ page }) => {
    await page.route('{{apiBaseUrl}}/{{entityName}}s', route =>
      route.fulfill({ status: 500, body: JSON.stringify({ error: 'Internal Server Error' }) })
    );
    const res = await page.request.get('{{apiBaseUrl}}/{{entityName}}s', { headers: validHeaders });
    expect(res.status()).toBe(500);
    const body = await res.json();
    expect(body.error ?? body.message).toBeTruthy();
  });

  // Edge case: error response has consistent shape
  test('all errors return JSON with error field', async ({ request }) => {
    const endpoints = [
      { method: 'get' as const, url: '{{apiBaseUrl}}/{{entityName}}s/000000', headers: validHeaders },
      { method: 'get' as const, url: '{{apiBaseUrl}}/{{entityName}}s' },
    ];
    for (const ep of endpoints) {
      const res = await request[ep.method](ep.url, { headers: ep.headers });
      if (res.status() >= 400) {
        const body = await res.json();
        expect(body.error ?? body.message ?? body.errors).toBeDefined();
      }
    }
  });
});
```

---

## JavaScript

```javascript
const { test, expect } = require('@playwright/test');

const headers = { 'Authorization': `Bearer {{apiToken}}`, 'Content-Type': 'application/json' };

test.describe('API Error Responses', () => {
  test('POST with invalid body returns 400', async ({ request }) => {
    const res = await request.post('{{apiBaseUrl}}/{{entityName}}s', {
      headers,
      data: { name: '' },
    });
    expect(res.status()).toBe(400);
  });

  test('no token returns 401', async ({ request }) => {
    const res = await request.get('{{apiBaseUrl}}/{{entityName}}s');
    expect(res.status()).toBe(401);
  });

  test('regular user on admin endpoint returns 403', async ({ request }) => {
    const res = await request.get('{{apiBaseUrl}}/admin/users', {
      headers: { 'Authorization': `Bearer {{userToken}}` },
    });
    expect(res.status()).toBe(403);
  });

  test('non-existent resource returns 404', async ({ request }) => {
    const res = await request.get('{{apiBaseUrl}}/{{entityName}}s/999999', { headers });
    expect(res.status()).toBe(404);
  });
});
```

## Variants
| Variant | Description |
|---------|-------------|
| 400 Bad Request | Invalid body → 400 + errors detail |
| 401 Unauthorized | No token → 401 |
| 403 Forbidden | Wrong role → 403 |
| 404 Not Found | Missing resource → 404 |
| 422 Unprocessable | Missing required field → 422/400 |
| 429 Rate Limit | Threshold exceeded → 429 |
| 500 Server Error | Mocked 500 → error body present |
| Consistent shape | All errors have error/message field |
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate 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 existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall