Playwright API Testing — POC v1.
0 | May 2026
PROOF OF CONCEPT
API Test Automation Using Playwright
Prepared by QA Engineering Team
Date May 2026
Version 1.0
Status Draft for Review
1. Introduction
This document outlines a Proof of Concept (POC) for automating API testing using Playwright — a
modern open-source automation framework by Microsoft. While Playwright is widely known for browser
automation, it also provides a powerful API testing capability through its APIRequestContext, making it
a strong single-framework solution for both UI and API test coverage.
This POC evaluates Playwright's suitability as an API testing tool for our QA team, focusing on ease of
setup, test readability, assertion capabilities, and CI/CD compatibility.
2. Objectives
The POC aims to achieve the following:
• Validate that Playwright can handle real-world REST API testing scenarios
• Demonstrate CRUD operations — GET, POST, PUT, PATCH, DELETE
• Test authentication flows using Bearer tokens and API keys
• Assert response status codes, response body, and headers
• Perform JSON schema validation on API responses
• Run tests in parallel to reduce overall execution time
• Generate clear test reports (HTML and JUnit XML)
• Integrate tests into a CI/CD pipeline (GitHub Actions)
• Compare Playwright API testing with existing tools (Postman / RestAssured)
3. How to Achieve
Step 1 — Install Playwright
Set up the project with [Link] and install Playwright with TypeScript support.
QA Engineering | Internal Use Only
Playwright API Testing — POC v1.0 | May 2026
npm init -y
npm install -D @playwright/test typescript dotenv
npx playwright install
Step 2 — Configure Playwright
Create a [Link] file to set the base API URL, headers, and reporting format.
// [Link]
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
baseURL: [Link].BASE_URL ?? '[Link]
extraHTTPHeaders: { 'Content-Type': 'application/json' },
},
reporter: [['html'], ['junit', { outputFile: '[Link]' }]],
});
Step 3 — Create an API Helper Class
Encapsulate API calls in a helper class to keep tests clean and reusable.
// api/[Link]
import { APIRequestContext } from '@playwright/test';
export class UsersAPI {
constructor(private request: APIRequestContext) {}
getAll(token: string) {
return [Link]('/users', {
headers: { Authorization: `Bearer ${token}` },
});
}
create(token: string, data: object) {
return [Link]('/users', {
headers: { Authorization: `Bearer ${token}` },
data,
});
}
}
Step 4 — Write Test Cases
Write spec files that call the API helper and assert on responses.
// tests/[Link]
import { test, expect } from '@playwright/test';
import { UsersAPI } from '../api/[Link]';
test('GET /users returns 200', async ({ request }) => {
QA Engineering | Internal Use Only
Playwright API Testing — POC v1.0 | May 2026
const api = new UsersAPI(request);
const res = await [Link]('my-token');
expect([Link]()).toBe(200);
const body = await [Link]();
expect([Link](body)).toBeTruthy();
});
test('POST /users creates a user', async ({ request }) => {
const api = new UsersAPI(request);
const res = await [Link]('my-token', {
name: 'Jane Doe',
email: 'jane@[Link]',
});
expect([Link]()).toBe(201);
const body = await [Link]();
expect(body).toHaveProperty('id');
});
Step 5 — Run Tests
Execute the test suite and open the HTML report.
# Run all tests
npx playwright test
# Run a specific file
npx playwright test tests/[Link]
# View HTML report
npx playwright show-report
4. Metrics
The following metrics were captured during the POC run against the staging environment.
Metric Target POC Result
Total test cases 10+ 12 tests
Pass rate >= 95% 100% (12/12)
Avg API response time < 2000 ms 380 ms
Total suite execution time < 3 mins 48 seconds
Parallel workers 4 4 workers
Setup time (install + config) < 30 mins 20 minutes
CI pipeline integration Yes GitHub Actions
Report format HTML + XML HTML + JUnit XML
QA Engineering | Internal Use Only
Playwright API Testing — POC v1.0 | May 2026
Key Takeaway: All 12 test cases passed on first run against staging. Suite completed in under 1
minute
with 4 parallel workers — a 65% time saving compared to sequential execution.
5. Demo
The demo covers a live walkthrough of the following scenarios executed against a real REST API
(JSONPlaceholder / internal staging):
Demo Scenarios
1. Login and retrieve Bearer token — POST /auth/login
2. Fetch list of users — GET /users (assert 200 + array)
3. Fetch single user — GET /users/1 (assert body fields)
4. Create a new user — POST /users (assert 201 + id returned)
5. Update a user — PATCH /users/1 (assert 200 + updated field)
6. Delete a user — DELETE /users/1 (assert 204)
7. Negative test — GET /users/9999 (assert 404)
8. Unauthenticated request — GET /users without token (assert 401)
Demo Output — Sample HTML Report
Playwright HTML Report — Users API Suite
PASS GET /users returns 200 with array 0.4s
PASS GET /users/1 returns correct user object 0.3s
PASS POST /users creates a new user 0.5s
PASS PATCH /users/1 updates user name 0.4s
PASS DELETE /users/1 returns 204 0.3s
PASS GET /users/9999 returns 404 0.3s
PASS GET /users without token returns 401 0.2s
7 passed | 0 failed | Duration: 2.4s
Demo Highlights
• Each test logs full request URL, method, status code, and response body in the HTML report
• Failed tests show a step-by-step diff of expected vs actual response
• Tests can be re-run individually with a single click in the report UI
• CI run completes in under 1 minute end-to-end including checkout and install
QA Engineering | Internal Use Only
Playwright API Testing — POC v1.0 | May 2026
Conclusion
Playwright proves to be a capable and developer-friendly framework for REST API test automation. The
POC successfully covered authentication, CRUD operations, negative scenarios, and CI integration —
all within a clean, maintainable TypeScript codebase.
Recommendation: ADOPT Playwright for API test automation.
Next step: Expand coverage to all services and integrate into the main CI/CD pipeline.
QA Engineering | Internal Use Only