Skip to content

Tests fail when run in non-UTC time zone #712

@justingrant

Description

@justingrant

🐛 Bug Report

The current immer tests will fail if the system time zone is not UTC, e.g. when running locally instead of in CI. I built a fix for this and will PR it shortly.

Link to repro

n/a (it only reproes locally)

To Reproduce

npm test

Observed behavior

 FAIL  __tests__/patch.js (5.203s)
  ● #676 patching Date objects

    expect(received).toMatchInlineSnapshot(snapshot)

    Snapshot name: `#676 patching Date objects 1`

    Snapshot: "2020-11-10T08:08:08.003Z"
    Received: "2020-11-10T16:08:08.003Z"

      1136 |    })
      1137 | 
    > 1138 |    expect(nextState.date.toJSON()).toMatchInlineSnapshot(
           |                                    ^
      1139 |            `"2020-11-10T08:08:08.003Z"`
      1140 |    )
      1141 |    expect(nextState.test.perform()).toBe("tested!")

      at Object.<anonymous> (__tests__/patch.js:1138:34)

  ● #676 patching Date objects

    expect(received).toMatchInlineSnapshot(snapshot)

    Snapshot name: `#676 patching Date objects 2`

    Snapshot: "2020-11-10T08:08:08.003Z"
    Received: "2020-11-10T16:08:08.003Z"

      1143 |    const rebuilt = applyPatches({}, patches)
      1144 |    expect(rebuilt.date).toBeInstanceOf(Date)
    > 1145 |    expect(rebuilt.date.toJSON()).toMatchInlineSnapshot(
           |                                  ^
      1146 |            `"2020-11-10T08:08:08.003Z"`
      1147 |    )
      1148 |    expect(rebuilt.date).toEqual(new Date(2020, 10, 10, 8, 8, 8, 3))

      at Object.<anonymous> (__tests__/patch.js:1145:32)

 › 2 snapshots failed.

Expected behavior

No failures.

Environment

We only accept bug reports against the latest Immer version.

  • Immer version:
  • I filed this report against the latest version of Immer
  • [(n/a)] Occurs with setUseProxies(true)
  • [(n/a)] Occurs with setUseProxies(false) (ES5 only)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions