16

Is there any way to know how long my tests take without doing it programmatically with Jest?

To be clear, I know that if I add a variable to get the current time before each test and then log this when my test completes I'll get this information, but I want this automatically, maybe with some Jest configuration.

Jonathan Irwin
  • 5,009
  • 2
  • 29
  • 48
R. Karlus
  • 2,094
  • 3
  • 24
  • 48

1 Answers1

27

You shouldn't need any configuration to get the running time for your tests

PASS  src/containers/Dashboard/Dashboard.test.tsx (12.902s)

That 12.902s in the brackets is the total time from when the test command was run.

If you want to see the running time per test you can run jest with the --verbose flag and it will show you the time for each test as well as the whole suite.

  Dashboard Container
    ✓ render without crashing (1090ms)
Jonathan Irwin
  • 5,009
  • 2
  • 29
  • 48
  • 1
    Ooops you're totally right, I was using the silent config. That's why it didn't appeared. – R. Karlus Jan 29 '20 at 18:13
  • 1
    @Jonathan Irwin, are you sure about your answer? I'm asking because I recently ran tests and the sum of all the times for each test under a suite is waaay less than the time in parentheses logged close to the suite on the console. I think it is the time it took the test to finish running from the time the command was initiated on the terminal, and not from when that exact suite started running, for the suite, not the unit in the suite – orimdominic Aug 13 '22 at 18:28
  • Yeah just tested and I think you are correct. In brackets seems to be the total running time. I will update. – Jonathan Irwin Aug 14 '22 at 14:54