Skip to content
Advertisement

Get tests running time with Jest

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.

Advertisement

Answer

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)
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement