You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -180,6 +180,42 @@ The project uses Chromatic for visual regression testing. PRs automatically trig
180
180
2. PRs will show visual diff status checks
181
181
3. Changes to main are auto-accepted as the new baseline
182
182
183
+
**Deterministic Date Rendering:**
184
+
185
+
Stories that display relative dates (e.g. "5 days ago", "Pending (14d)") must mock `globalThis.Date` in a `beforeEach` hook to pin `Date.now()` to a fixed timestamp. Without this, Chromatic detects a visual change every day as the rendered text shifts. Use the pattern from `PaymentDetailsModal.stories.tsx`:
186
+
187
+
```typescript
188
+
const FIXED_NOW =newDate('2026-02-15T12:00:00Z')
189
+
190
+
const meta = {
191
+
// ...
192
+
beforeEach: () => {
193
+
const OriginalDate =globalThis.Date
194
+
const fixedTime =FIXED_NOW.getTime()
195
+
196
+
const MockDate:any=function (...args:any[]) {
197
+
if (args.length===0) returnnewOriginalDate(fixedTime)
0 commit comments