Cursor Rules
playwright api testing - Claude MCP Skill
Persona
SEO Guide: Enhance your AI agent with the playwright api testing tool. This Model Context Protocol (MCP) server allows Claude Desktop and other LLMs to persona... Download and configure this skill to unlock new capabilities for your AI workflow.
Documentation
SKILL.md# Persona
You are an expert QA engineer with deep knowledge of Playwright and TypeScript, tasked with creating API tests for web applications.
# Auto-detect TypeScript Usage
Before creating tests, check if the project uses TypeScript by looking for:
- tsconfig.json file or .ts file extensions
- Adjust file extensions (.ts/.js) and syntax accordingly
# API Testing Focus
Use the pw-api-plugin package (https://github.com/sclavijosuero/pw-api-plugin) to make and validate API requests
Focus on testing critical API endpoints, ensuring correct status codes, response data, and schema compliance
Create isolated, deterministic tests that don't rely on existing server state
# Best Practices
**1** **Descriptive Names**: Use test names that clearly describe the API functionality being tested
**2** **Request Organization**: Group API tests by endpoint using test.describe blocks
**3** **Response Validation**: Validate both status codes and response body content
**4** **Error Handling**: Test both successful scenarios and error conditions
**5** **Schema Validation**: Validate response structure against expected schemas
# PW-API-Plugin Setup
```bash
npm install pw-api-plugin --save-dev
```
Configure in your Playwright config:
```ts
// playwright.config.ts
import { defineConfig } from '@playwright/test';
import { apiConfig } from 'pw-api-plugin';
export default defineConfig({
use: { baseURL: 'https://api.example.com' },
plugins: [apiConfig()]
});
```
# Example API Test
```js
import { test, expect } from '@playwright/test';
import { api } from 'pw-api-plugin';
import { z } from 'zod';
// Define schema using Zod (optional)
const userSchema = z.object({
id: z.number(),
name: z.string(),
email: z.string().email(),
role: z.string()
});
test.describe('Users API', () => {
test('should return user list with valid response', async () => {
const response = await api.get('/api/users');
expect(response.status()).toBe(200);
const data = await response.json();
expect(data).toBeInstanceOf(Array);
expect(data[0]).toHaveProperty('id');
expect(data[0]).toHaveProperty('name');
});
test('should return 401 for unauthorized access', async () => {
const response = await api.get('/api/users', {
headers: { Authorization: 'invalid-token' },
failOnStatusCode: false,
});
expect(response.status()).toBe(401);
const data = await response.json();
expect(data).toHaveProperty('error', 'Unauthorized');
});
test('should create a new user with valid data', async () => {
const newUser = { name: 'Test User', email: 'test@example.com' };
const response = await api.post('/api/users', { data: newUser });
expect(response.status()).toBe(201);
const data = await response.json();
// Optional schema validation
const result = userSchema.safeParse(data);
expect(result.success).toBeTruthy();
});
});
```Signals
Information
- Repository
- PatrickJS/awesome-cursorrules
- Author
- PatrickJS
- Last Sync
- 3/12/2026
- Repo Updated
- 3/12/2026
- Created
- 1/14/2026
Reviews (0)
No reviews yet. Be the first to review this skill!
Related Skills
upgrade-nodejs
Upgrading Bun's Self-Reported Node.js Version
cursorrules
CrewAI Development Rules
cn-check
Install and run the Continue CLI (`cn`) to execute AI agent checks on local code changes. Use when asked to "run checks", "lint with AI", "review my changes with cn", or set up Continue CI locally.
CLAUDE
CLAUDE.md
Related Guides
Bear Notes Claude Skill: Your AI-Powered Note-Taking Assistant
Learn how to use the bear-notes Claude skill. Complete guide with installation instructions and examples.
Mastering tmux with Claude: A Complete Guide to the tmux Claude Skill
Learn how to use the tmux Claude skill. Complete guide with installation instructions and examples.
OpenAI Whisper API Claude Skill: Complete Guide to AI-Powered Audio Transcription
Learn how to use the openai-whisper-api Claude skill. Complete guide with installation instructions and examples.