Skip to content

Scheduling infrastructure for absolutely everyone.

938 B
Raw Blame

title: Timezone Handling in Tests impact: HIGH impactDescription: Timezone bugs are hard to reproduce without consistent test environments tags: testing, timezone, consistency

Timezone Handling in Tests

Always Use TZ=UTC

When running tests in the Cal.diy repository, use the TZ=UTC environment variable:

TZ=UTC yarn test

This ensures consistent timezone handling and prevents timezone-related test failures that might occur when tests are run in different environments or by different developers with varying local timezone settings.

Why This Matters

  • Tests may pass locally but fail in CI (or vice versa)
  • Date/time assertions become unpredictable
  • Debugging timezone issues is time-consuming

Test Commands

# Unit tests
TZ=UTC yarn test

# Specific test file
TZ=UTC yarn vitest run path/to/file.test.ts

# E2E tests (already configured in yarn e2e)
PLAYWRIGHT_HEADLESS=1 yarn e2e