Back to Cal

Timezone Handling in Tests

agents/rules/testing-timezone.md

6.2.0752 B
Original Source

Timezone Handling in Tests

Always Use TZ=UTC

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

bash
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

bash
# 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