From ce4c5dd584442c5bebc4bb18f71588ffcfa9746c Mon Sep 17 00:00:00 2001 From: Aamer Akhter Date: Sun, 5 Jul 2026 21:49:31 -0400 Subject: [PATCH] test(types): stop asserting Date.now() timestamps are deep-equal createInitialRalphTrackerState() stamps lastActivity: Date.now(). The 'should create fresh instances each time' test deep-equaled two factory results, so two calls straddling a millisecond boundary differed by 1ms and failed intermittently (e.g. PR #139 CI: 1782927694581 vs ...580). Exclude the dynamic lastActivity from the equality check and assert it is a number separately, preserving the test's intent (distinct instances with identical initial field values) without the timing race. --- test/types.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/types.test.ts b/test/types.test.ts index 0f1b67f0..81c2ffab 100644 --- a/test/types.test.ts +++ b/test/types.test.ts @@ -101,7 +101,14 @@ describe('types utility functions', () => { const state2 = createInitialRalphTrackerState(); expect(state1).not.toBe(state2); - expect(state1).toEqual(state2); + // `lastActivity` is stamped with Date.now(), so two calls that straddle a + // millisecond boundary differ by 1ms. Compare the rest of the initial + // state for equality and assert the timestamp is a number separately. + const { lastActivity: lastActivity1, ...rest1 } = state1; + const { lastActivity: lastActivity2, ...rest2 } = state2; + expect(rest1).toEqual(rest2); + expect(typeof lastActivity1).toBe('number'); + expect(typeof lastActivity2).toBe('number'); }); it('should have correct types for all fields', () => {