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

restore dayjs timezone tests #500

Merged
merged 1 commit into from
Jul 20, 2021

Conversation

HegelPro
Copy link
Contributor

No description provided.

@@ -3,6 +3,8 @@ import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import MockDate from 'mockdate';

const systemTimeZone = dayjs().format('Z');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we mock the timezone instead (set dayjs to use a certain predetermined timezone in the tests)?

This can make the tests more robust / independent from environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried 3 ways, none of them worked:

  1. With package for mock timezone. It conflicts with the other package mockdate.
  2. Redefine dayjs package for jest with dayjs's method .tz() . dayjs() and dayjs.tz() work in different ways.
  3. Set default timezone for jest with TZ env. variable. The problem is, that it doesn't work for windows. I can't set a default timezone on windows. nodejs/node#4230

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's leave it as it is for now.

@HegelPro HegelPro merged commit 7aa971f into master Jul 20, 2021
@HegelPro HegelPro deleted the lp/test/249/restore_dayjs_timezone_tests branch July 20, 2021 14:54
@HegelPro HegelPro linked an issue Jul 29, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Day.js configure timezones
2 participants