Rayrun
← Back to videos

Playwright - Turn your hooks into fixtures

How to convert your playwright hooks into test fixtures.

In this video, software developer Jared from Commit Quality demonstrates how to transition from using hooks to custom fixtures in your code for enhanced functionality and maintainability. He starts by explaining the benefits of fixtures over traditional "before" and "after" hooks, which include encapsulation of setup and tear-down in one place, reusability across multiple test files, flexibility to suit specific needs, and more.

Jared then jumps into live-coding to demonstrate the creation of custom fixtures in a test class. He elaborates on how to utilize these fixtures in a test and how they allow you to tailor setup and tear down according to the needs of your test. Jared also emphasizes that such setups would typically be kept in separate classes, not within the test file.

He proceeds by running tests on the code he's written which demonstrate how the custom fixtures behave, and takes time to debug a minor issue with duplicate titles, lending more depth to the tutorial by showing common coding issues and how to resolve them.

Finally, Jared gives a small hint on what his future tutorial videos will cover, including the creation of page object models and how to extend them using the fixture methodology. Throughout the video, he recommends viewers to learn and try these coding practices to improve the quality of their tests and ultimately, their software's reliability and efficiency.

Related Videos

#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
Create feature, steps & config | Playwright & Cucumber - Typescript | Part 1
Create feature, steps & config | Playwright & Cucumber - Typescript | Part 1
Playwright Test Fixtures Made Easy
Playwright Test Fixtures Made Easy
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 luc@ray.run.