← Back to Discord Forum

Set test options within a fixture

.milkncheeseposted in #help-playwright
Open in Discord

Im looking to set some test options that I would set in test.use, like timezoneId, in a test fixture. How would I go about doing this?

This thread is trying to answer question "How can I set test options like timezoneId within a test fixture?"

5 replies

Sorry 🫠


Hi, from my somewhat outdated experience, I believe it works pretty much the same as overriding regular fixtures: https://playwright.dev/docs/test-fixtures#overriding-fixtures

I would create a new fixture with a new context that has the different time zone. Additionally I would add a new page fixture that uses this new context. And in my tests instead of page I would use the new page fixture.

Overriding the context fixture itself and add conditions into it to change settings like timezone would also be okay.

But I don't think that using test.use in a new fixture that controls your setting is possible (that's how I understand your initial approach). I would assume (I don't know for sure, never tested it) that the order of fixture setup would be problematic. And the context fixture might get setup before your control fixture would update the settings.

Related Discord Threads

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.