From the course: Playwright: Design Patterns

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Automatic fixtures

Automatic fixtures

- [Instructor] In this lesson, we'll expand on fixtures we created earlier for handling test data by introducing automatic fixtures in Playwright. We'll see how they simplify setup tasks like user authentication by running setup and tear down logic automatically without needing explicit references in task cases. So as you can see, we have got the same code. I'm going to create a new fixture here, authenticatedUser, and async. This time I will use the page, which is a built-in fixture and the test data, the custom fixture that we have created. And the second parameter is the callback function, which is the use. All I'm doing over here is copying the logic for signing in and putting it into the fixture. Now, this is a normal fixture. To create an automatic fixture, I will have to convert this authenticatedUser into an array so that it can take fixture configuration options. So now that, as you can see, authenticatedUser is an array, I can pass in the object, which is going to tell…

Contents