Closed ezzatron closed 1 day ago
timezoneId
doesn't exist on providerOptions
. You can add @vitest/browser/providers/playwright
to your types to get better Type Hint support. Does this help?
export default defineConfig({
test: {
browser: {
providerOptions: {
context: {
timezoneId: 'Asia/Jakarta'
}
}
}
}
})
Yes, that does work. Thank you!
P.S. I did try adding @vitest/browser/providers/playwright
to my tsconfig.json
but for some reason the type hints aren't working for me in the real project where I had this issue (I didn't use TypeScript in the repro). It's probably a TypeScript config issue of some kind. The other types (@vitest/browser/matchers
) are working for expect.element
etc.
FWIW I updated the repro repo at https://github.com/ezzatron/vitest-browser-mode-timezone-repro to use TypeScript. Those @vitest/browser/providers/playwright
types still don't seem to work for me. I put some extra properties in the providerOptions
and there's no TypeScript errors when you run npx tsc --noEmit
.
Describe the bug
When using Vitest Browser Mode to test some code that depends on a timezone, I noticed that setting the
TZ
environment variable only affects the time zone for Chromium and Firefox browsers, when running the tests on macOS.It seems as though this issue does not happen on Linux.
For contrast, I tried using Playwright Test and setting the timezone via the
timezoneId
option, and this works fine under macOS. So I don't think it's an inherent limitation of the Playwright provider. Setting the same option via Vitest Browser Mode Provider Configuration seems to have no effect at all.Reproduction
I've created a minimal reproduction as a GitHub repo, because this issue can only be reproduced under macOS: https://github.com/ezzatron/vitest-browser-mode-timezone-repro
You can see the test suite results in this GitHub Actions workflow run show that under macOS, Chromium and Firefox are working, but WebKit is not (from the macos job):
Linux is working fine (from the linux job):
I also tested Windows, which didn't seem to work for any browser.
System Info
Used Package Manager
npm
Validations