How to test and monitor your APIs with Playwright



AI Summary

This video demonstrates how to use Microsoft Playwright not only for end-to-end browser testing but also for API testing. The presenter uses a GraphQL API from countries.trevorblades.com as an example, explaining the basics of GraphQL queries and how to shape API responses. The tutorial shows how to write Playwright tests using the request object to make HTTP POST requests to the API, parse the JSON response, and validate the data with assertions. The presenter highlights writing multiple assertions for API responses, including checking the number of items returned and filtering data by country code. The video also covers how to configure Playwright projects specifically for API tests and mentions the integration of these tests into CI/CD pipelines and synthetic monitoring tools like Checkly, which can run Playwright code on schedules from multiple locations for production monitoring and alerting. The video is a practical guide for developers looking to extend Playwright’s use for HTTP/GraphQL API testing and monitoring.