Hazyzh/jest-html-reporters

Collapsable Test Groups

duckbrain opened this issue ยท 7 comments

Is your feature request related to a problem? Please describe.
I have a few test suites (*.test.[tj]s files) that have over 100 tests that are grouped with the describe function. These tests go through a sequence of steps in a workflow and check to make sure each step is done correctly. Each describe group is a different iteration of the steps.

jest-html-reporters shows these flattened out to show "description -> test". When I expand one of the files that follow that workflow, I end up with a very long list of tests that are clipped by the describe name and the test is cut off.

Describe the solution you'd like
A way to collapse test groups the same way test suites are grouped together. with an expand button.

Describe alternatives you've considered
Splitting my test into smaller chunks of files. It doesn't make a lot of logical sense to do that in my case.

Related #6

We know that this reporter just to display the data that we got form Jest. In fact, I have the same request as you, I don't want to show all test at one abstract level, but the data we get from Jest is a bit annoying, in the reporter's data they put all data in an array, not a tree-like structure Object.

here is an example.
structure example

The structure of my test file is

- Group 1
  - Sub Group 1
     - case 1
     - case 2
     - case 3
  - Sub Group 2
     - case 4
     - case 5
     - case 6

But the output data from Jest just put all tests in one array, not have any structure.

So the key point of this feature is how to combine those data into a tree-like structure.

Follow above, In the Jest native data, there is one field we can use to combine data into a tree-like structure. it is the field ancestorTitle, it put all parents describe texts in an array, such as the ancestorTitle of test 1 is [group 1, sub group 1].

For now, I will use this field to combine data. it may not perfectly accurate if you set identical describe wordings, but it can cover most use cases.

so the current design is that if a test file has many test cases, it will show a Merge Data checkbox on the expanded table. You can check it to merge data and set the merge level to control how to combine those data.

for example,
if you set merge level as 1, it will show like this
level 1
set merge level as 2, it will show like this
level 2

@duckbrain do you have any suggestions about this? any comments welcome!

Yeah, that looks nice.

I'd prefer to have the redundant prefix stripped from the test name as well, as that would address my original problem of the names being cut off.

New version (2.0.0) released. You can have a try now.

Hey, guys, it is possible to get the merge data checked as default?

Hey, guys, it is possible to get the merge data checked as default?

Have you been able to find any solution for this to get merge data as checked by default?