How to Use Playwright to Validate an API Response Schema (PWT-Native and Zod)



AI Summary

This video demonstrates using Microsoft Playwright for API testing, focusing on API schema validation. The presenter covers three test cases with local APIs: a simple GET endpoint, a POST endpoint creating resources, and a more complex GET endpoint with variable responses including arrays and nullable fields. The video shows how to use Playwright’s request fixture for making API calls, basic assertions using ‘expect’ for response status and body matching, and using ‘expect.any’ for flexible type validation. For complex schema validation, the Zod TypeScript-first JSON validation library is introduced to parse and enforce detailed response schemas. The presenter plans a follow-up video on custom Playwright assertions for schema validation. The video is from the Czechly channel, which focuses on extending Playwright tests into synthetic monitoring for proactive API and app health checks.