Get Requester | Bondar Academy
Course: Playwright API Testing with TypeScript
Module: Building a Framework
Instructor: Artem Bondar
Lesson Summary
Summary of the Lesson: In this lesson, we created a custom method getRequest to perform an API request using our custom request handler. Here are the key steps and concepts covered: Creating the getRequest Method Defined a new method getRequest responsible for sending API requests. Utilized a constant URL obtained from the previously created getURL method. Made a GET request using Playwright's request method. Handling Headers and TypeScript Issues Specified headers using API headers and addressed TypeScript type issues by defining it as a Record . Ensured the getRequest method is asynchronous to handle promises with await . Improving the Testing Process Integrated status code validation directly into the getRequest method. Allowed passing the expected status code as an argument, simplifying test assertions. Demonstrated the new structure by creating a test for retrieving tags, which also passed successfully. Conclusion: The getRequest method streamlines the API request process by handling common tasks like status code validation and JSON response retrieval, making tests cleaner and easier to maintain. Future lessons will focus on further improvements and additional features.