Tests Structure | Bondar Academy
Course: Playwright UI Testing with TypeScript
Module: Getting Started with Playwright
Instructor: Artem Bondar
Lesson Summary
In this lesson, we continue working with Playwright and begin using a practice application that was cloned from GitHub. The main objectives of this lesson include: Installing Playwright into the application Making initial configurations Organizing the test structure Writing the first lines of code Understanding the concept of promises and the await keyword Setting Up Playwright To install Playwright, run the following command: npm init playwright@latest --force After installation, we will see the playwright.config and package.json files updated. We will create a new test file named firsttest.spec.ts in the test folder. Writing Tests To write tests, we need to import the test method from the Playwright library: import { test } from 'playwright-test'; Each test can accept two parameters: the name of the test and the test method itself, using the arrow function syntax. Grouping Tests Tests can be grouped into suites using test.describe , allowing for separate contexts and preconditions for different sets of tests. Using Promises and Await When using Playwright methods that return a promise, it is crucial to use the await keyword to avoid race conditions: await page.goto('http://localhost:4200'); Remember, await can only be used in asynchronous functions, so always declare your function with async . Summary In this lesson, we: Installed Playwright Created a test file Wrote our first test Learned about the importance of using await with promise-returning methods Thank you for joining, and see you in the next lesson!