Playwright API Testing Practice: TypeScript Automation Labs
Master asynchronous API test automation using Playwright APIRequestContext and TypeScript. Execute requests against live mock services, assert JSON payloads, and validate contracts with instant grading.
import { test, expect } from '@playwright/test';
test('authenticate and create order', async ({ request }) => {
// 1. Authenticate
const authRes = await request.post('/api/practice/auth/token', {
data: { username: 'qa@target.dev', password: 'Test@123' }
});
expect(authRes.status()).toBe(200);
const { token } = await authRes.json();
expect(token).toBeDefined();
// 2. Fetch authenticated profile
const profileRes = await request.get('/api/practice/auth/me', {
headers: { Authorization: `Bearer ${token}` }
});
expect(profileRes.status()).toBe(200);
});Curriculum Labs
Hands-On Practice Exercises
Module 1: HTTP fundamentals
Understand requests, responses, and status codes.
- 1Send a GET request and assert 200Easy 12m
- 2Read and assert a response headerEasy 12m
- 3Assert the content-type headerEasy 12m
- 4Understand 2xx status codesEasy 12m
- 5Understand 4xx status codesEasy 12m
- 6Understand 5xx status codesEasy 12m
- 7Assert the response timeMedium 25m
- 8Inspect a JSON response bodyEasy 12m
Module 2: Requests & methods
Exercise the full set of HTTP verbs.
- 1Create a resource with POSTEasy 12m
- 2Read a resource with GETEasy 12m
- 3Replace a resource with PUTMedium 25m
- 4Update a field with PATCHMedium 25m
- 5Delete a resource and verifyMedium 25m
- 6Send query parametersEasy 12m
- 7Send path parametersEasy 12m
- 8Send custom request headersMedium 25m
- 9Send a form-urlencoded bodyMedium 25m
Module 3: Working with JSON
Parse, extract, and assert on payloads.
Module 4: Schema & contracts
Validate response shape and types.
Module 5: Authentication
Test every common auth mechanism.
Module 6: Authorization & negative testing
Probe boundaries and error paths.
Module 7: Data-driven & parameterization
Cover permutations efficiently.
Module 8: GraphQL
Query and validate GraphQL APIs.
Module 9: Mocking & virtualization
Isolate services with mocks.
Module 10: Integration, performance & CI
Ship trustworthy API suites.
Want the Full 64-Challenge API Testing Curriculum?
Our comprehensive track covers HTTP fundamentals, JSON extraction, OAuth2 token rotation, rate limits, GraphQL, and downstream microservice mocking.
Frequently Asked Questions About Playwright API (TypeScript & JS) Practice
Why practice API testing with Playwright?↓
Playwright includes a high-performance APIRequestContext that allows QA teams to seed test data, authenticate, and validate backend endpoints alongside or independently of browser UI tests.
Does this require installing Node.js or @playwright/test locally?↓
No. You can write and execute TypeScript and JavaScript API test scripts directly in the TargetQA editor with instant execution and automated assertion grading.