---
title: Knowledge Check | Playwright API Testing Tutorial
description: Nine questions on the decisions that matter most when API tests and UI
  tests share one Playwright suite. Each answer comes with a short explanation, so
  a…
source_url:
  html: https://testingbot.com/resources/courses/playwright-api-testing/knowledge-check
  md: https://testingbot.com/resources/courses/playwright-api-testing/knowledge-check.md
---

Course

[Playwright API Testing Tutorial](https://testingbot.com/resources/courses/playwright-api-testing)

Chapter 9 of 9

1. [1 Playwright API Testing: a Hands-On Course](https://testingbot.com/resources/courses/playwright-api-testing)
2. [2 The request Fixture and APIRequestContext](https://testingbot.com/resources/courses/playwright-api-testing/the-request-fixture)
3. [3 Asserting Status, Headers and JSON](https://testingbot.com/resources/courses/playwright-api-testing/asserting-status-headers-and-json)
4. [4 Authentication: Tokens, Test Accounts and storageState](https://testingbot.com/resources/courses/playwright-api-testing/authentication-and-tokens)
5. [5 Test Data Setup and Teardown Through the API](https://testingbot.com/resources/courses/playwright-api-testing/test-data-setup-through-the-api)
6. [6 Schema Validation with zod and ajv](https://testingbot.com/resources/courses/playwright-api-testing/schema-validation)
7. [7 Mocking APIs with page.route](https://testingbot.com/resources/courses/playwright-api-testing/mocking-with-page-route)
8. [8 Running API and UI Tests in CI and on a Cloud Grid](https://testingbot.com/resources/courses/playwright-api-testing/ci-and-the-cloud-grid)
9. [9 Knowledge Check](https://testingbot.com/resources/courses/playwright-api-testing/knowledge-check)

[Exit course](https://testingbot.com/resources/courses)

 Chapter 9 of 9 Intermediate 6 min read Updated Nov 2026 

# Knowledge Check

Nine questions on the decisions that matter most when API tests and UI tests share one Playwright suite. Each answer comes with a short explanation, so a wrong answer points you back to the right chapter.

1. Your config has three projects, `api`, `chromium` and `firefox`, but no `testDir` per project. What happens to a file of pure API tests?

 It runs once, in the `api` project, because it only uses `request` It runs three times, once per project, although no browser is involved It fails in the browser projects because `request` is not available there

Projects run every test file they match, regardless of the fixtures a test uses. Giving each project its own `testDir` (or `testMatch`) keeps API tests in one project.

2. Inside a test in the `chromium` project (whose `baseURL` is the UI host), you call `playwright.request.newContext()` without options and then `get('/products')`. Where does the request go?

 Nowhere: a context without `baseURL` rejects relative paths To the API host, because it is an API client To the UI host, because contexts created in a test inherit the project's options you did not pass

Request contexts created during a test pick up the project's `use` options for anything not set explicitly. Pass `baseURL` yourself when the API lives on another host.

3. A test checks that deleting an order works: it calls `DELETE /orders/7` and asserts `toBeOK()`. What should it add to really prove the delete?

 A follow-up `GET /orders/7` that expects `404` `failOnStatusCode: true` on the delete A longer request timeout

A success status is the server's claim. Reading the record back is what shows it is gone; `failOnStatusCode` only changes how an error status is reported.

4. Four workers share one test customer account. A test asserting "the cart has exactly one item" fails about once in five runs. What is the structural fix?

 Add `retries: 3` Run the suite with `--workers=1` forever A worker-scoped fixture that creates one account per worker through the API

Workers run in parallel on the same account and change each other's data. One account per worker isolates them and keeps the parallelism; retries only hide the collision.

5. You override `storageState` in your base `test` with a fixture that logs in through the API. API-only tests now take noticeably longer. Why?

 The `request` fixture now starts a browser Playwright resolves `storageState` for every test, so each API test also runs the login it never uses `storageState` objects are slower than files

The built-in context options, including `storageState`, are set up for every test. A login hidden in that override runs for API tests too. Put it in a separate fixture layer that only UI tests import.

6. A fixture creates a project through the API, calls `use()`, then deletes it, wrapped in `try { ... } catch {}` so cleanup never fails a test. What is the risk?

 A broken delete endpoint goes unnoticed and test data quietly piles up The delete runs before the test None: cleanup errors are never relevant

Swallowing every cleanup error hides real bugs. Accept the specific outcomes you expect (for example 204 or 404 if the test may have deleted it already) and let anything else fail.

7. Which statement about a consumer-written zod schema and the API's published OpenAPI schema is accurate?

 They are equivalent, so validating against one is enough The published schema checks that the API matches its own documentation; the consumer schema checks that it returns what this client needs, including required fields the documentation may not mark as required Only the published schema can check nested objects

They answer different questions. Published schemas often list properties without marking them required, so a response missing fields can still validate. The consumer schema is the one that protects your front end.

8. You want a UI test of the "search is down" state. Which approach fits?

 Ask the backend team to stop the search service during the run Call the search endpoint with `request` using an invalid token `page.route` on the search URL with `route.fulfill({ status: 500 })`, registered before the page searches

Routing lets one test break one endpoint for one browser context without touching shared infrastructure. A request through `request` does not affect what the page sees.

9. Your API tests and UI tests run with one config whose browser projects connect to a cloud grid. Which tests open grid sessions?

 Only tests in the remote browser projects; the API project runs in the local Node process All tests, because the config has `connectOptions` Only tests that call `page.request`

`connectOptions` is set per project. Tests in the API project never ask for a browser, so they open no session and run on the machine that started the run.

Check answers

## Where to go next[#](https://testingbot.com#where-to-go-next)

If you have not yet worked through the browser side in depth, the [Playwright tutorial](https://testingbot.com/resources/courses/playwright) covers locators, debugging and parallel runs. To run your suite on more browsers and operating systems, the [Playwright documentation for TestingBot](https://testingbot.com/support/web-automate/playwright) lists every option. The official [Playwright API testing guide](https://playwright.dev/docs/api-testing) and the [zod documentation](https://zod.dev) are both worth reading end to end.

[Previous · Chapter 8 Running API and UI Tests in CI and on a Cloud Grid](https://testingbot.com/resources/courses/playwright-api-testing/ci-and-the-cloud-grid)
## You finished Playwright API Testing Tutorial

Put what you learned into practice. Run your tests on 6100+ real browsers and physical iOS and Android devices.

[Start free trial](https://testingbot.com/users/sign_up) [See pricing](https://testingbot.com/pricing) [Browse other courses](https://testingbot.com/resources/courses)

## TestingBot Playwright API Testing Certification

Turn this course into a free, resume-worthy credential: pass the exam, run the course suite on TestingBot, and get a verifiable certificate for your LinkedIn profile.

[How it works](https://testingbot.com/resources/courses/playwright-api-testing/certification)
