Rayrun
← Back to videos

Anatomy of a Playwright test

A beginner friendly overview, describing the structure of a playwright test

In the video, the host Jared takes us through the process of creating a basic Playwright test. He starts off from a blank slate Playwright configuration, commenting out projects for the purpose of the tutorial. After setting up, Jared jumps into the test file, initially titled example.spec.ts. To start, Jared imports the Playwright test module to enable the creation of test declarations and assertions.

He proceeds to discuss the anatomy of the test suite from the import code line to the test function itself. He highlights the use of asynchronous functions and the importance of the 'await' keyword. The explanation revolves around the concept of 'Promises' in JavaScript, which he explains using the analogy of a child promising to give away a toy but never stating when. Using 'await' in the code makes sure all lines of code are resolved before moving to the next.

Jared then dives deep into the code inside the test body, focusing on how to visit a webpage and assert its title. Here, he features the use of locators and explains how to use various methods to interact with web elements.

The last part of the video involves a walkthrough on how to run the test suite from the terminal using the Playwright extension. After running the test, he reminds viewers that the title of the playwright website is indeed 'Playwright,' helping to affirm the test's passed status.

Towards the end, Jared gives a teaser for the next video topic, a deep dive into assertions.

Related Videos

Playing Your Tests Wright with VS Code
Playing Your Tests Wright with VS Code
#16 - ARIA and how Playwright is making use of it to identify UI controls?
#16 - ARIA and how Playwright is making use of it to identify UI controls?
Playwright with UI Mode is awesome
Playwright with UI Mode is awesome
Setup & Re-Use Authentication with Playwright Dependencies!
Setup & Re-Use Authentication with Playwright Dependencies!
TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].