Skip to content

Relative duration rounding tests#3288

Merged
ptomato merged 7 commits intomainfrom
relative-duration-rounding-tests
Mar 3, 2026
Merged

Relative duration rounding tests#3288
ptomato merged 7 commits intomainfrom
relative-duration-rounding-tests

Conversation

@ptomato
Copy link
Collaborator

@ptomato ptomato commented Mar 3, 2026

This tests many different combinations of largestUnit, smallestUnit, roundingMode, roundingIncrement, and relativeTo, checking that the invariant holds:

duration.round({ ...options, relativeTo })

must give the same duration as

relativeTo.until(relativeTo.add(duration), options)

I wanted to make this into a snapshot test as well, but there was really no way to cover enough of the testing space while keeping the snapshot file within GitHub's 100 MB file size limit.

Also a couple of cleanups for the snapshot tests, and a change to the CI configuration so that they only run when you add the label "run snapshot tests". Currently they take 15-20 minutes to run on CI, which is a bit much if you're only making a textual change.

ptomato added 4 commits March 2, 2026 17:00
If every subsecond component is ≤999, there's no need to list them out
separately - there won't be any ambiguity in the serialized string. This
makes the snapshot files a bit smaller and will save some space in the
large durationroundingrelative.snapshot.json.
This makes sure that the invariant holds even without constraining.
This tests many different combinations of largestUnit, smallestUnit,
roundingMode, roundingIncrement, and relativeTo, checking that the
invariant holds:

    duration.round({ ...options, relativeTo })

must give the same duration as

    relativeTo.until(relativeTo.add(duration), options)

I wanted to make this into a snapshot test as well, but there was really
no way to cover enough of the testing space while keeping the snapshot
file within GitHub's 100 MB file size limit.
This changes the snapshot tests CI job to not run unless the label
"run snapshot tests" is applied to the PR. (The snapshot tests take
15-20 minutes on CI, which is a bit much if you're just changing
something in the spec text.)
@ptomato ptomato requested a review from Ms2ger March 3, 2026 01:06
@ptomato ptomato added the run snapshot tests Add this label to a PR if you want the snapshot tests to run on it. label Mar 3, 2026
Copy link
Collaborator

@justingrant justingrant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Maybe add some text to the readme to explain the magic label needed to run these?

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.40%. Comparing base (be4e0ef) to head (b5ce7d8).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3288   +/-   ##
=======================================
  Coverage   97.40%   97.40%           
=======================================
  Files          22       22           
  Lines       10771    10771           
  Branches     1866     1866           
=======================================
  Hits        10492    10492           
  Misses        258      258           
  Partials       21       21           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

ptomato added 3 commits March 2, 2026 17:59
Apparently I made a JSON file that couldn't be read.
V8 unflagged Temporal, so there's no longer any need for this argument.
@ptomato
Copy link
Collaborator Author

ptomato commented Mar 3, 2026

Looks good. Maybe add some text to the readme to explain the magic label needed to run these?

Thanks for the review. I looked at adding it to the readme but it seemed out of place there, since we don't have any other contributing instructions. I've added a PR template instead, so contributors will see it when they open their PR.

@ptomato ptomato merged commit 89fcd06 into main Mar 3, 2026
6 checks passed
@ptomato ptomato deleted the relative-duration-rounding-tests branch March 3, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run snapshot tests Add this label to a PR if you want the snapshot tests to run on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants