How to group tests in AVA test runner?

1.1k views Asked by At

First of all, thank you for this lib!

My query, is there any way to group tests in AVA? Let's say I have four tests cases at present like:

test('Group #1 - Test sum #1', t => t.is(m.sum(20, 10), 30));
test('Group #1 - Test sum #2', t => t.is(m.sum(20, -10), 10));
test('Group #2 - Test sub #1', t => t.is(m.sub(20, 10), 10));
test('Group #2 - Test sub #2', t => t.is(m.sub(20, -10), 30));

So at present, all of them show together in the terminal when I run ava in verbose output mode using -v option like:

√ <file name> » Group #1 - Test sum #1
√ <file name> » Group #1 - Test sum #2
√ <file name> » Group #1 - Test sub #1
√ <file name> » Group #1 - Test sub #2

Is there any grouping function in AVA, so that I could see result somewhat like:

√ <file name> » Group #1
                  Test sum #1
                  Test sum #2
√ <file name> » Group #2
                  Test sub #1
                  Test sub #2

I looked into issues#222 also but could figure out which one to use. I also looked in ava-spec, but that is also not working properly. Also, it seems to be outdated and was last updated 8 months ago.

Looking forward to your response. Thanks!

1

There are 1 answers

0
Mark Wubben On BEST ANSWER

There is not. I doubt we'll implement that at all, and in any case, it won't be any time soon.

AVA runs tests concurrently across processes, and prints the results as they come in. Printing grouped output will mean buffering results for each group until all tests in that group have finished. Our reporters currently aren't up to that task. I don't think it's particularly useful either.

Perhaps at some point we'll have more detailed log output that 3rd party reporters can use. Then this reporting style could be built on top of AVA. But this isn't the current priority.