qunitjs / js-reporters

📋 Common Reporter Interface (CRI) for JavaScript testing frameworks.
MIT License
60 stars 18 forks source link

Spec: Combine the "Test" and "Suite" concepts #129

Closed Krinkle closed 3 years ago

Krinkle commented 3 years ago

Status quo

The TAP 13 specification does not standardise a way of describing parent-child relationships between tests, nor does it standardise how to group tests.

Yet, all major test frameworks have a way to group tests (e.g. QUnit module, and Mocha suite) and/or allow nesting tests inside of other tests (like tape, and node-tap). While the CRI draft provided a way to group tests, it did not accomodate Tap. They would either need to flatten the tests with a separator symbol in the test name, or to create an implied "Suite" for every test that has non-zero children and then come up with an ad-hoc naming scheme for it.

Note that the TAP 13 reporter we ship, even after this change, still ends up flattening the tests by defaut using the greater than > symbol, but at least the event model itself recognises the relationships so that other output formats can make use of it, and in the future TAP 14 hopefully will recognise it as well, which we can then make use of.

Ref https://github.com/TestAnything/testanything.github.io/pull/36.

Summary of changes

See the diff of test/integration/reference-data.js for the concrete changes this makes to the consumable events.

Caveats

Misc

Fixes https://github.com/js-reporters/js-reporters/issues/126.

Krinkle commented 3 years ago

For a quick overview, see diff of the test fixture: reference-data.js and summary-reporter.js.

/cc @isaacs @ljharb Could use a second pair of eyes on this. The effective difference is quite straight-forward but there are a number of caveats I outlined above. It'd be great if you could confirm that the listed caveats are indeed accepted status quo with node-tap and TAP, or whether there's perhaps another way that I missed. Thanks!