Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
justingrant opened this issue Nov 27, 2020 · 1 comment · Fixed by #705
Closed
1 task done

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

justingrant opened this issue Nov 27, 2020 · 1 comment · Fixed by #705
Labels

Comments

@justingrant
Copy link
Contributor

🐛 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)
justingrant added a commit to justingrant/immer that referenced this issue Nov 27, 2020
Fixes immerjs#712 by initializing all Date instances with UTC values,
not local-timezone values.
@mweststrate
Copy link
Collaborator

🎉 This issue has been resolved in version 8.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants