How a time-zone mismatch caused a test to fail every morning and pass every afternoon
A developer at WatchNext discovered an intermittent test failure in their air-date countdown app while making unrelated changes to a privacy page and footer. The failing test checked whether an episode airing tomorrow was counted as one day away, but it was occasionally returning two days instead. Investigation revealed the bug was pre-existing and not caused by the recent edits, confirmed by running the test suite after reverting all changes. The root cause was a calendar mismatch: the test built 'tomorrow' using JavaScript's toISOString(), which always outputs UTC dates, while the production function deliberately calculated day differences in America/Los_Angeles time. This meant that during the roughly seven-to-eight hours each day when UTC had rolled over to a new date but Los Angeles had not, the two sides of the assertion were measuring from different calendars, causing the test to fail.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in