Jest does not seem to properly handle process.env.TZ
: Setting process.env.TZ does not affect Dates
To reproduce:
-
Install dependencies
npm ci
-
Run the tests; this demonstrates the bug
npm test
-
Run the tests with
TZ=UTC
; theTZ=EST
test will failTZ=UTC npm test
-
Run the tests with
TZ=EST
; theTZ=UTC
test will failTZ=EST npm test
-
The
TZ
environment variable can be overridden directly injest.config.js
(https://stackoverflow.com/a/58238786/399105) -
Use Jest's
setupFiles
configuration option to point to a setup file that setsTZ
(https://stackoverflow.com/a/58953365/399105) -
Hardcode
TZ
in any scripts inpackage.json
that call Jest, e.g."scripts": { "test": "TZ=UTC jest",