Tests Structure | Bondar Academy
Course: Playwright UI Testing with TypeScript
Module: Getting Started with Playwright
Instructor: Artem Bondar
Lesson Summary
This lesson covers the organization of tests in Playwright by creating a new spec file from scratch. Here are the key points discussed: Creating a New Spec File Start by importing the test function from the Playwright test library. The test function represents a single unit of a test and requires two arguments: Test Name: A unique name for the test. Callback Function: The body of the test, defined using arrow function syntax. Grouping Tests Use test.describe to group tests into suites, allowing for better organization. Tests can be visually expanded or collapsed in your code editor. Using Fixtures The page fixture represents a new blank browser page. Common methods include page.goto() to navigate to a URL. Handling Promises Methods like goto return a Promise , which requires the use of await for proper execution. Make the callback function asynchronous when using await . Methods that are not promises, like page.locator , do not require await . Summary To write tests in Playwright: Import the test function. Define test name and body. Use the page fixture for browser interactions. Utilize await for promise-returning methods. By following these steps, you can effectively structure and run tests using Playwright.