Skip to content

Run the full test suite against both temporal-polyfill and @js-temporal/polyfill #16

Description

@dogmar

Motivation

The library no longer bundles a Temporal implementation — callers must provide one (see the temporal prop docs), and we recommend two polyfills:

These are independent implementations and can differ in edge-case behavior (parsing, toLocaleString/calendar handling, overflow, DST). To be confident the library works on both, every test should run against both — not just the reference implementation.

Current state

  • package/src/test-temporal.ts exports a temporalVariants matrix, but after the mini-shim removal it has a single entry (@js-temporal/polyfill).
  • Only a few suites consume the matrix via describe.each(temporalVariants): utils.test.ts, keyboard.test.ts.
  • ~10 suites hardcode @js-temporal/polyfill directly instead of using the matrix: calendar-provider.test.tsx, month-view.test.tsx, weeks-view.test.tsx, overflow.test.ts, compute-weeks-in-window.test.ts, resolve-first-week.test.ts, weeks-keyboard.test.ts, grid.perf.test.tsx, grid.event-perf.test.tsx.
  • temporal-polyfill (fullcalendar) is not a devDependency yet (only @js-temporal/polyfill is).

Proposed work

  • Add temporal-polyfill (fullcalendar) as a devDependency (via the pnpm catalog).
  • Add it as a second entry in temporalVariants (package/src/test-temporal.ts), shaped as a TemporalNamespace like the existing entry.
  • Migrate every hardcoded suite to source its Temporal from temporalVariants and wrap its cases in describe.each(temporalVariants)("… ($name)", ({ T }) => { … }), so each test executes once per polyfill. Replace the local temporal/Temporal constants accordingly.
  • Decide and document how perf suites (grid.perf.test.tsx, grid.event-perf.test.tsx) participate — run on both, or pin to one with a noted rationale (matrixing perf benchmarks may just double runtime without added signal).
  • Make describe.each(temporalVariants) the default pattern for new date-dependent tests (note in CONTRIBUTING or a comment in test-temporal.ts).

Acceptance criteria

  • vp run -r test executes the full date-dependent suite once per polyfill, and passes on both.
  • Adding a third implementation later means only adding one entry to temporalVariants.
  • No test file imports a polyfill directly except test-temporal.ts (and any intentionally-pinned perf suite).

Notes

Some assertions are format-sensitive (e.g. PlainYearMonth.toString(), toLocaleString output). Where the two polyfills format differently, prefer semantic assertions (compare via Temporal.X.compare, check fields) over exact-string matches, or branch on the variant where unavoidable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions