Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Could we please implement possibility to change timezon inside test #26996

Closed
LiutskoOlga opened this issue Sep 11, 2023 · 2 comments
Closed

Comments

@LiutskoOlga
Copy link

Let us know what functionality you'd like to see in Playwright and what your use case is.
Do you think others might benefit from this as well?

We need to test functionality related to timezone, when person in one timezone create data and user from another timezone change the date
Unfortunately,

  • set time zone via config use this value globally for test
  • use Intl.DateTimeFormat().resolvedOptions().timeZone = 'timezone' is not applied too.
@dgozman
Copy link
Contributor

dgozman commented Sep 12, 2023

@LiutskoOlga Take a look at this guide. You can set a timezone for a single file or describe block like this:

test.use({
  timezoneId: 'Europe/Berlin',
});

If you would like to have two users from different timezones in a single test, you should create two browser contexts and pass different timezoneId options to them.

const user1Context = await browser.newContext({ timezoneId: 'Europe/Berlin' });
const user2Context = await browser.newContext({ timezoneId: 'Europe/Paris' });

Let me know whether this helps.

@dgozman
Copy link
Contributor

dgozman commented Sep 14, 2023

It seems like the issue has been resolved. If you still encounter problems, please file a new issue with a repro and link to this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants