Skip to content

Strict equal not working with Temporal dates #7991

@AndreVelde

Description

@AndreVelde

Describe the bug

Currently when the dates are not the same when using Temporal dates which I added based on the temporal-polyfill it will return that the dates are the same when using toStrictEqual on a object. Not sure if I am doing something wrong or if there is a issue.

Reproduction

Test:

it('should fail on different instant dates', () => {
  const date = Temporal.Now.instant();

  const object1 = {
      id: '123',
      lastUpdated: date,
  };
  const object2 = {
      id: '123',
      lastUpdated: date.add({ minutes: 30 }),
  };

  // This now passes when removing not
  expect(object1).not.toStrictEqual(object2);
});

it('should fail on different zoned dates', () => {
    const date = Temporal.Now.zonedDateTimeISO('UTC');

    const object1 = {
        id: '123',
        lastUpdated: date,
    };
    const object2 = {
        id: '123',
        lastUpdated: date.add({ days: 1 }),
    };

   // This now passes when removing not
    expect(object1).not.toStrictEqual(object2);
});

Package.json:

"dependencies": {
   "temporal-polyfill": "0.3.0"
},

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 12.81 GB / 63.73 GB
  Binaries:
    Node: 22.13.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.3.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (130.0.2849.80)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @vitest/coverage-istanbul: ^3.1.3 => 3.1.3
    @vitest/eslint-plugin: ^1.2.0 => 1.2.0
    @vitest/spy: ^3.1.3 => 3.1.3
    vitest: ~3.1.3 => 3.1.3

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    P2 - 2

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions