jest icon indicating copy to clipboard operation
jest copied to clipboard

[Feature]: Show progress of tests as they run

Open Dreamsorcerer opened this issue 1 year ago • 11 comments

🚀 Feature Proposal

Even with verbose enabled, Jest doesn't give any indication of progress through tests within a file while they are being run.

Motivation

If it's taking a long time for tests to complete, I have no indication how far through the tests it is, whether it's hanging on a particular test or just slowly progressing through tests.

Example

For comparison, pytest (the most popular test runner on Python projects) displays the result of each test as it runs, looking something like:

tests/test_admin.py::test_path PASSED                                    [  1%]
tests/test_admin.py::test_js_module PASSED                               [  2%]
tests/test_admin.py::test_no_js_module PASSED                            [  3%]

Dreamsorcerer avatar Jan 07 '24 18:01 Dreamsorcerer

Hi @Dreamsorcerer What do you think about adding the percentage at the end of the test suite? See the example below

image

WillianAgostini avatar Jan 08 '24 23:01 WillianAgostini

Anything that shows some progress while it's running would be an improvement. Displaying the results of each test as they complete though, can be more helpful, as you can figure out what test the runner is stuck on (particularly useful in weird edge cases where the runner itself ends up hanging and never completing).

Dreamsorcerer avatar Jan 09 '24 00:01 Dreamsorcerer

I see that it is better to add it at the end of the Test suite, as placing it next to each test can get confusing when several tests occur in parallel and so this percentage shows the percentage of all tests

WillianAgostini avatar Jan 09 '24 01:01 WillianAgostini

I think the request was for progress within a single test file, not the total (which we already have, albeit not as a percentage).

So I think it should be next to a RUNS (and nothing for completed ones) rather than in the summary. Probably behind some sort of option? This feels more line a continuation of #6616 with more precise data rather than doing math on the data we already display

SimenB avatar Jan 09 '24 09:01 SimenB

I misunderstood the original question. The percentage is really not important, you can do whatever you want to do with it (pytest does show the global percentage after each test, but is also, most often, run in a synchronous manner). The main point is that I should be able to see some output after each test, and can figure out which test the runner is stuck on if it were to freeze/crash.

Dreamsorcerer avatar Jan 10 '24 21:01 Dreamsorcerer

What if we were to add the 'X passed' field next to the path description indicating how many test were completed? Is this approach useful @Dreamsorcerer @SimenB? image

WillianAgostini avatar Jan 12 '24 01:01 WillianAgostini

Yeah, that looks good to me! Maybe out of a total per test file as well? I think we have this information available

SimenB avatar Jan 12 '24 10:01 SimenB

If you mean that the number is updated as each test passes (as opposed to a total shown at the end of the file run), then that's probably good enough.

Dreamsorcerer avatar Jan 12 '24 13:01 Dreamsorcerer

@SimenB Should we exclude the percentage at the conclusion of the test suite?

It would be beneficial to display a percentage out of the total for each test file too but I couldn't locate any property that provides this value before or during the execution of the file.

WillianAgostini avatar Jan 12 '24 21:01 WillianAgostini

@SimenB @Dreamsorcerer I found a way to display the total number of pending tests. To achieve this, I had to search within the Jasmine and JestAdapter classes. Below is the screenshot showing the outcome, and here is the commit for the changes in 230b11b29d7739a11d607f7efd2f4e5e511b2b26.

image

WillianAgostini avatar Jan 18 '24 01:01 WillianAgostini

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Feb 17 '24 01:02 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

Dreamsorcerer avatar Feb 23 '24 00:02 Dreamsorcerer

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Mar 24 '24 00:03 github-actions[bot]

Up

WillianAgostini avatar Mar 24 '24 00:03 WillianAgostini