Flaky Test
tests/unit/SubscriptionUtilsTest.ts intermittently fails on:
SubscriptionUtils › isUserOnFreeTrial › should return true if the current date is on the same date of free trial start date
FAIL tests/unit/SubscriptionUtilsTest.ts
● SubscriptionUtils › isUserOnFreeTrial › should return true if the current date is on the same date of free trial start date
at Object.toBeTruthy (tests/unit/SubscriptionUtilsTest.ts:200:76)
Test Suites: 1 failed, 116 passed, 117 total
Tests: 1 failed, 2 skipped, 1917 passed, 1920 total
Seen on: Expensify/App#93054 — test (job 7) (unrelated PR; the failure has nothing to do with that PR's changes).
Likely cause
The test depends on the real system clock rather than fake timers. It captures firstDayFreeTrial from new Date() and then calls isUserOnFreeTrial(...), which re-reads new Date() at call time:
tests/unit/SubscriptionUtilsTest.ts:192-201
Because the two new Date() reads happen at slightly different moments (and can straddle a second/minute/day boundary), the free-trial window comparison can evaluate to false, so the toBeTruthy() assertion fails non-deterministically.
Suggested fix
Freeze time in this suite (e.g. jest.useFakeTimers().setSystemTime(...) or inject a fixed "now") so the boundary date/time comparisons are deterministic, then restore real timers in teardown. The same clock-dependent pattern applies to the sibling isUserOnFreeTrial cases, so consider stabilizing them together.
This is a pre-existing flaky test, not a regression from any specific PR.
Flaky Test
tests/unit/SubscriptionUtilsTest.tsintermittently fails on:Seen on: Expensify/App#93054 —
test (job 7)(unrelated PR; the failure has nothing to do with that PR's changes).Likely cause
The test depends on the real system clock rather than fake timers. It captures
firstDayFreeTrialfromnew Date()and then callsisUserOnFreeTrial(...), which re-readsnew Date()at call time:tests/unit/SubscriptionUtilsTest.ts:192-201Because the two
new Date()reads happen at slightly different moments (and can straddle a second/minute/day boundary), the free-trial window comparison can evaluate tofalse, so thetoBeTruthy()assertion fails non-deterministically.Suggested fix
Freeze time in this suite (e.g.
jest.useFakeTimers().setSystemTime(...)or inject a fixed "now") so the boundary date/time comparisons are deterministic, then restore real timers in teardown. The same clock-dependent pattern applies to the siblingisUserOnFreeTrialcases, so consider stabilizing them together.This is a pre-existing flaky test, not a regression from any specific PR.