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

fix: ensure durations are integers in json formatter #2094

Merged
merged 2 commits into from
Jul 28, 2022

Conversation

davidjgoss
Copy link
Contributor

@davidjgoss davidjgoss commented Jul 28, 2022

🤔 What's changed?

Ensure the nanoseconds duration in the JSON formatter is an integer.

The way we derived a single nanoseconds number from a duration object was prone to rounding errors:

(1043459 / 1000000) * 1000000
// 1043458.9999999999

We now do it a slightly different way and Math.floor the result to be sure. This is consistent with what some of the helpers from messages do (and why the message formatter was not affected even though we were providing higher resolution timestamps since 8.0.0).

⚡️ What's your motivation?

Fixes #2086.

🏷️ What kind of change is this?

  • 🐛 Bug fix (non-breaking change which fixes a defect)

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@coveralls
Copy link

coveralls commented Jul 28, 2022

Coverage Status

Coverage increased (+0.01%) to 93.144% when pulling 3ac7d04 on fix/json-formatter-duration-integer into fb3144e on main.

@davidjgoss davidjgoss merged commit d547f78 into main Jul 28, 2022
@davidjgoss davidjgoss deleted the fix/json-formatter-duration-integer branch July 28, 2022 14:09
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.

An option to disable the performance counter on demand.
2 participants