Fix: Date-related test failures due to UTC/local timezone mismatch Issue #7878
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Two test files were failing due to timezone-related issues:
packages/@mantine/dates/src/components/Month/get-date-in-tab-order/get-date-in-tab-order.test.tsreturns current day"2025-05-22"(UTC)"2025-05-23"(local KST)packages/@mantine/dates/src/components/Day/Day.test.tsxadds data-today attribute if date is the same as todaydata-todayattributeRoot Cause
The tests were using
new Date().toISOString().split('T')[0]which returns dates in UTC. This caused failures when the local date (e.g., KST, UTC+9) was different from the UTC date. For example, when it's May 23 in KST, it's still May 22 in UTC.Solution
In
get-date-in-tab-order.test.ts:returns current daytest to usedayjs().format('YYYY-MM-DD')for getting the current local datemonthparameter with the local dateIn
Day.test.tsx:dayjsimportdayjs().format('YYYY-MM-DD')when passing thedateprop to theDaycomponentCode Style:
Testing
Additional Notes
When writing tests that involve dates, it's important to be explicit about timezones. Using
dayjs()without parameters ensures we're working with the local timezone, which is typically what we want for date component tests.