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

Add new to DateTimeFormat invocation #181

Merged
merged 1 commit into from Apr 28, 2022
Merged

Conversation

TrevorSayre
Copy link
Contributor

@TrevorSayre TrevorSayre commented Apr 27, 2022

In our project we mock Intl.DateTimeFormat in order to quickly run tests against various timezones. I understand your preferred method differs, but this had been working for us up to version 1.1.4 quite nicely.

In 1.1.5 a commit introduced isValidTimezoneIANAString which invokes Intl.DateTimeFormat without new. When mocking, this causes the error Uncaught TypeError: Class constructor DateTimeFormatFake cannot be invoked without 'new' which subsequently causes an Invalid Date error. The fix is as simple as adding new, which shouldn't affect anyone who isn't mocking, but may help those who would like to.

@marnusw
Copy link
Owner

marnusw commented Apr 27, 2022

Thank you. I'll sort this later today. If you'd like to contribute an example of how you run your tests to the docs that would be much appreciated as it sounds like something others might benefit from.

@TrevorSayre
Copy link
Contributor Author

Thank you! I'll look into writing up an example of how we do our jest tests across multiple timezones.

@marnusw marnusw merged commit cfff8fd into marnusw:master Apr 28, 2022
@marnusw
Copy link
Owner

marnusw commented Apr 28, 2022

1.3.4

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.

None yet

2 participants