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

Improve timing related tests #2107

Merged
merged 2 commits into from
Mar 20, 2023
Merged

Improve timing related tests #2107

merged 2 commits into from
Mar 20, 2023

Conversation

jnyrup
Copy link
Contributor

@jnyrup jnyrup commented Mar 20, 2023

This PR consists of two commits related to timing:

  1. JavaScript's Date.now() is documented as

The Date.now() static method returns the number of milliseconds elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC.

C# DateTime.Now on the other hand is documented as:

Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.

If running a test while changing from/to DST, the difference between two calls to DateTime.Now is no longer only an approximation of the time to run some code, but also the difference in UTC offsets.
By changing usages of DateTime.Now to DateTime.UtcNow we remove that "race-condition" and brings the intention closer to the puppeteer tests.

The second commit includes idea from #2090 (comment) to avoid silently ignoring exceptions in some tests.
@amaitland I did see your wish for a more elegant solution, but do you agree that including the less pretty solution for now is better than keeping status quo?

@kblok kblok merged commit 70baffd into hardkoded:master Mar 20, 2023
@jnyrup jnyrup deleted the time branch March 22, 2023 14:27
@amaitland
Copy link
Contributor

but do you agree that including the less pretty solution for now is better than keeping status quo?

@jnyrup Absolutely 👍 I've rewritten a couple of cases (#2096) where ContinueWith wasn't necessary, that's as far as I've got so far.

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.

3 participants