Little confused about how/when to use fixtures aside from the basic fixtures like page, request, browser, etc.
Should I be thinking about it like dependency injection?
Which is the preferred pattern?
Is it even valid to be thinking about fixtures in this way?
test('test1', async ( { page, loginPage} ) => { loginPage.login(); }
vs.
import {LoginPage} from '../login.page';
test('test1', async ( { page} ) => { const loginPage = new LoginPage(page); loginPage.login(); }
This thread is trying to answer question "Should page objects be injected into tests as fixtures or imported normally?"
I have multiple page fixtures for different kind of authorization (regular persistent test user, admin user, temporary isolated test user, worker shared test user,...) so I need to replace 'page' with my different page fixtures every time when initializing my Pom depending on the test case. Having a fixture for every case did not seem beneficial for me so far.
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].