API testing with the request fixture
Call the Daily List server directly with Playwright's request fixture, check the answers, and use it to set up data fast.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: phoning the kitchen instead of waiting for the waiter. The waiter carries an order to the kitchen. A phone call asks the kitchen a direct question. It is faster, and it still works when the waiter is having a bad day. It does not prove the waiter carried the plate.
Daily List is a to-do list app. The page is the waiter. The server behind it is the kitchen. Tom, the tester, wants to know the server can save a task. He does not need to click buttons for that.
What it is: Playwright is a library that drives a real browser. This slice is the , a helper that sends Hypertext Transfer Protocol (HTTP) calls with no page. The behind it remembers the base address and the headers. The nearest neighbour is the page itself, which is what you use when the bug is in the screen. Postman and curl are other neighbours: they send calls too, but they are not the test runner.
Why it matters: Some bugs never show in the browser, and some setup is painful to click. puts a task in place in a fraction of a second. A page test can then check what Lily sees, without repeating the create-task clicks.
A direct call proves the server answered. It does not prove the button works. Keep a browser test for the screen.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named here are made up.)
PLAIN WORDS · 2 in this section
- playwright
- a free Microsoft tool that drives a browser for tests
- hypertext
- text that links to other pages
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Testing the server directly, and setting up data fast, without going through the screens.
- Ask for the helper
- Send the call
- Check the status
- Read it back
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The kitchen | The server |
| The waiter | The web page |
| Phoning the kitchen | A direct call with the request fixture |
| The kitchen's answer | The status code and the body |
WHERE THIS PICTURE STOPS
- A phone call does not show whether the waiter carries the plate well. Direct calls cannot find a broken button.
- A real kitchen has one phone line. A test can open many contexts.
- The cooks can still burn the soup. A good status does not prove the data is right.
HOOK
Phone the kitchen.
REMEMBER IT THIS WAY
A rule of thumb: if you see this, think that.
If you only need to know the server can save a task, phone the kitchen instead of clicking through the page.
| In the trick | What it stands for |
|---|---|
| Phone the kitchen | a direct call with the request fixture |
| Answer | the status code and the body |
A direct call cannot show that the page itself looks right.
TELL A FRIEND
Phoning the kitchen to ask if it can make soup, instead of asking the waiter.
OFTEN MIXED UP WITH Designing API tests. application programming interface () test design says which cases to try. This lesson shows how to send them with Playwright.
Sources & standards — 5 sources
- Market practice
Application programming interface (API) testing (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
- Market practice
APIRequestContext (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Request methods, failOnStatusCode, timeout, retries, cookie ownership and disposal. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: Request methods, failOnStatusCode, timeout, retries, cookie ownership and disposal. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
- Market practice
APIResponseAssertions (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: toBeOK fixed response status. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: toBeOK fixed response status. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
- Market practice
Hypertext Transfer Protocol (HTTP) request methods (Mozilla developer docs) ↗ — Mozilla (MDN Web Docs) · What the request methods GET, POST, PUT, PATCH and DELETE mean (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Playwright 1.65.0 response matcher implementation ↗ — Microsoft (Playwright) · Playwright v1.65.0 pinned source: toBeOK reads a captured APIResponse status once, accepts 200–299, and does not resend the request; toPass retries its callback. Inspected 6 November 2026; source contract, not an upstream execution claim.
Actual pinned source section inspected during the completed v45 analysis. Framework source is Apache-2.0, distinct from the documentation CC BY 4.0 licence. Upstream tests were not executed.
PRACTISE AND KEEP
Sources for this topic — 6 sources
- Market practice
Application programming interface (API) testing (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
- Market practice
APIRequestContext (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Request methods, failOnStatusCode, timeout, retries, cookie ownership and disposal. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: Request methods, failOnStatusCode, timeout, retries, cookie ownership and disposal. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
- Market practice
APIResponseAssertions (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: toBeOK fixed response status. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: toBeOK fixed response status. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
- Market practice
Hypertext Transfer Protocol (HTTP) request methods (Mozilla developer docs) ↗ — Mozilla (MDN Web Docs) · What the request methods GET, POST, PUT, PATCH and DELETE mean (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Request (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Request methods and postDataJSON. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: Request methods and postDataJSON. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
- Market practice
Playwright 1.65.0 response matcher implementation ↗ — Microsoft (Playwright) · Playwright v1.65.0 pinned source: toBeOK reads a captured APIResponse status once, accepts 200–299, and does not resend the request; toPass retries its callback. Inspected 6 November 2026; source contract, not an upstream execution claim.
Actual pinned source section inspected during the completed v45 analysis. Framework source is Apache-2.0, distinct from the documentation CC BY 4.0 licence. Upstream tests were not executed.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.