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.
This commit is contained in:
Aamer Akhter
2026-07-05 21:49:31 -04:00
parent 4dfdbcd100
commit ce4c5dd584
+8 -1
View File
@@ -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', () => {