Rayrun
← Back to videos

Playwright Fixtures | Playwright Tutorial - part 34

Playwright Test is based on the concept of the test fixtures. Test fixtures are used to establish an environment for each test, giving the test everything it needs and nothing else. Test fixtures are isolated between tests, which gives Playwright Test following benefits:

The video is a tutorial on using fixtures in the Playwright test runner. The host explains that fixtures are an important feature and there are two types: test fixtures and worker fixtures. The video focuses on the test fixture and demonstrates how to create a custom fixture.

The host starts by creating a new file called "my-fixtures.ts" which serves as the base file for the fixture. They import the test function from the Playwright test runner and declare a type called kaushik which includes a string variable called hey. They then create a new variable called fixture and use the extend function to extend the baseTest fixture, passing in the kaushik type as the generic. Within the fixture function, they write their test code, accessing the hey variable within a test block.

The host then creates a test file called "my-test.test.ts" where they import the myFixture and use it to create a test. They log the value of hey and then use the expect function to assert that the value is uppercase. They run the test and demonstrate that it passes. They also demonstrate how to access the testInfo object within a test, showing the status of the test.

The host concludes the video by summarizing the key points about fixtures and mentioning that they will cover more topics related to fixtures in future videos.

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
Playwright - Turn your hooks into fixtures
Playwright - Turn your hooks into fixtures
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 [email protected].