Skip to content

Blog post: Tests vs. time zones #4

Description

@mrh-is

See the PR: https://github.com/Kidfund/ios/pull/482

Storyline

  • Write tests that differ by the value of a date
  • Use date as part of filename for snapshots
  • Tests are great, good job me
  • Push
  • CI servers don't like snapshot tests
  • ???
  • Oh, their filenames are different from the ones on my machine
  • Oh, the hour is different
  • Oh, looks like the time zone must be weird
  • Try to fix by setting time zone to GMT for tests
  • Fixes filename problem, but now the UI is wrong
    • Date formatter in UI uses default time zone
    • Tests think time is at midnight (GMT), UI thinks time is 7pm the night before
    • Tests technically pass, but they no longer test the real UX
  • How to fix both?
  • Just write time zone–insensitive data to filename!
    • That way, each machine can reinterpret it for its own time zone
  • Change filename outputted to use protocol
  • Add protocol conformance to Date
  • Blammo, everyone's happy

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions