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

console.timeEnd reporting seconds as milliseconds #6448

Closed
HiDeoo opened this issue Jun 12, 2018 · 4 comments
Closed

console.timeEnd reporting seconds as milliseconds #6448

HiDeoo opened this issue Jun 12, 2018 · 4 comments

Comments

@HiDeoo
Copy link
Contributor

HiDeoo commented Jun 12, 2018

🐛 Bug Report

When using console.time & console.timeEnd in a test, the logged elapsed time is indicated as being in milliseconds while actually being in seconds.

To Reproduce

Use console.time & console.timeEnd in a test:

it('should add two numbers', () => {
  console.time('test')

  expect(add(1, 2)).toBe(3);

  console.timeEnd('test')
});

Expected behavior

If the elapsed time is 7ms, I expect console.timeEnd to actually logs either:

  • test: 7ms
  • test: 0.007s

I'm assuming the current behavior is coming from these lines which convert the elapsed time in seconds and then log them in ms.

https://github.com/facebook/jest/blob/9c1c3b1f072175e434943d1eb99d84b4d72ed458/packages/jest-util/src/Console.js#L130-L131

Link to repl or repo (highly encouraged)

Repl.it demo.

Run npx envinfo --preset jest

  System:
    OS: macOS High Sierra 10.13.5
    CPU: x64 Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
  Binaries:
    Node: 10.3.0 - /usr/local/bin/node
    Yarn: 1.7.0 - /usr/local/bin/yarn
    npm: 6.1.0 - /usr/local/bin/npm
@thymikee
Copy link
Collaborator

Mind fixing that? :)

@HiDeoo
Copy link
Contributor Author

HiDeoo commented Jun 13, 2018

Sounds like a plan :)

@SimenB
Copy link
Member

SimenB commented Oct 16, 2018

#6456

@SimenB SimenB closed this as completed Oct 16, 2018
@github-actions
Copy link

This issue 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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants