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

Use UTC date string in tests to be timezone independent #705

merged 1 commit into from Jan 11, 2021


Copy link

@Gelio Gelio commented Nov 21, 2020

I noticed that one of the tests failed when run locally (I am in the CET timezone ATM), because the stringified date did not match the snapshot (was 1 hour off):


This probably stems from the fact that the Date constructor parses the values as though they were in the local timezone (CET +1 for me). Going back to UTC (which is what toJSON produces) subtracts that 1 hour, which makes it show 7:08:08 instead of 8:08:08.

I reckon using a UTC string could solve the problem. Another alternative would be using a constructor with a UNIX timestamp, but I reckon the current solution is more readable.

Fixes #712

Previously tests could break when run in a different timezone.
Copy link

@codesandbox-ci codesandbox-ci bot commented Nov 21, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2aca904:

Sandbox Source
Immer sandbox Configuration

Copy link

@mweststrate mweststrate commented Jan 11, 2021

Thanks for fixing this!

@mweststrate mweststrate merged commit e8fd805 into immerjs:master Jan 11, 2021
1 check passed
@Gelio Gelio deleted the fix-timezone-issue-in-test branch Jan 11, 2021
Copy link

@mweststrate mweststrate commented Jan 20, 2021

🎉 This PR is included 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
None yet

Successfully merging this pull request may close these issues.

2 participants