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: display test duration even if time is mocked out #7264

Merged
merged 5 commits into from
Oct 24, 2018

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Oct 24, 2018

Summary

As discussed in #7259. I'm not sure why Jasmine does not have the same issue. I don't care enough to dig though, this fixes it for Circus 🙂

Test plan

Integration test added.


declare module 'convert-hrtime' {
declare export default (
hrtime: [number, number],

This comment was marked as outdated.

@@ -240,7 +241,12 @@ export const callAsyncCircusFn = (

export const getTestDuration = (test: TestEntry): ?number => {
const {startedAt} = test;
return startedAt ? Date.now() - startedAt : null;
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously it was missing completely when time was fakes as startedAt === 0 which was falsy. using hrtime it changed to always say 0ms. The babel plugin ensures we reference the real process.hrtime now

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the millisecond resolution from Date.now enough or is there any other reason to use process.hrtime?

Copy link
Member Author

Choose a reason for hiding this comment

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

In theory it's more accurate, although I don't think that matters in practice.
Any reason to prefer Date?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't need a more accurate precision than milliseconds we can stick to Date. I'd prefer it for simplicity.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed back, but fixed the startedAt === 0 case

@codecov-io
Copy link

Codecov Report

Merging #7264 into master will increase coverage by <.01%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7264      +/-   ##
==========================================
+ Coverage   66.52%   66.53%   +<.01%     
==========================================
  Files         241      241              
  Lines        9308     9310       +2     
  Branches        6        5       -1     
==========================================
+ Hits         6192     6194       +2     
  Misses       3113     3113              
  Partials        3        3
Impacted Files Coverage Δ
packages/jest-circus/src/utils.js 19.83% <0%> (ø) ⬆️
packages/jest-util/src/install_common_globals.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f524e3a...4b4bada. Read the comment docs.

Copy link
Contributor

@rubennorte rubennorte left a comment

Choose a reason for hiding this comment

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

Look good. Thanks!

@SimenB SimenB merged commit e21ae11 into jestjs:master Oct 24, 2018
@SimenB SimenB deleted the test-duration branch October 24, 2018 20:29
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants