Search code examples
intellij-pluginvitest

Custom timezone for tests when running from intellij IDEA


I am trying to migrate tests from jest to vitest. For all of my tests I need to use UTC timezone. Currently, I was able to achieve it by TZ=UTC in package.json (refer: https://github.com/vitest-dev/vitest/issues/1575#issuecomment-1171085461).

"scripts": {
    "dev": "vite",
    "serve": "vite preview",
    "build": "vite build",
    "test": "TZ=UTC vitest run",
    "test:watch": "TZ=UTC vitest"
  }

My all the tests pass successfully when I am running the tests from CLI by using npm test. But when it comes to run tests from intellij looks like the tests aren't picking the timezone information from package.json. Is it expected behaviour?

I am using v0.6.6 of vitest runner and IntelliJ IDEA 2022.2.3.


Solution

  • You should specify this option in the JetBrains screen instead of package.json, as they are not using CLI as you. https://blog.jetbrains.com/webstorm/2022/11/webstorm-2022-3-beta/ Example of where to put this info