lecture 4 of 170 completed

Check what the API returned

A reply can have the expected fields and still answer a different request. Check both.

What you'll learn

  • Inspect an unknown value before reading its fields.
  • Distinguish a missing field from a valid but incorrect reply.
  • Check whether the API answered the request you made.

const talks = body as Talk[] looks convincing. The server renamed title to heading. Your test still tries to read title and gets undefined.

You asked an invented arts programme for talks that are still open. An API is how one program asks another for data. A request is the question it sends. A response is the reply. If those words are new, read the API testing guide.

as Talk[] tells TypeScript which type to assume. It never inspects the reply. We need different checks for an unreadable reply and a readable but wrong answer.

full course

Keep reading with the full course

The Foundations track and the first lessons in each framework are free. This lesson needs full course access. A course plan includes all lessons for Playwright, Cypress and Selenium.

See course plans →