Closed
Description
What is the problem this feature will solve?
The test runner currently only generates TAP output. Users would like a way to author and use reporters in a format other than TAP.
What is the feature you are proposing to solve the problem?
Now that the TAP parser has landed, it would be nice to define some type of reporter API built on top of the parser output. Node should probably ship one reporter that is easier on the eyes than TAP, and can serve as an example of how to create a reporter.
I think at a minimum we would want an API that:
- Generates
'test'
events. This would include the test name, result, and meta information such as the test duration, comments/user logs, and error information if the test fails. - Properly represents test nesting. This should work for both
test()
anddescribe()
/it()
style tests. - Handle warnings that are generated for things like extraneous asynchronous activity.
- Maybe the test summary - the part that says how many tests passed, failed, etc. We may want to surface this information, but leave it up to the reporter implementer whether they want to use it, or track the counts on their own. Right now, the CLI runner reports how many test files passed or failed. A reporter author could be more interested in counting individual
test()
s, or may want to count nested tests in different ways.
What alternatives have you considered?
There are some existing reporters on npm already. However, I think they have a few drawbacks:
- Many seem to be unmaintained or buggy.
- It is possible for Node to produce valid TAP and have a reporter consume that TAP, but still have less than ideal output. For example, a recent issue comment mentioned seeing confusing output because
tap-arc
was looking for specific fields in the TAP output. Neither Node nortap-arc
were wrong here andtap-arc
has an open issue to work better with Node's test runner. It would be nice to build something that is guaranteed to work with Node's runner. - Anything currently on npm needs to use another TAP parser to parse the test runner output. This is wasteful because Node is already doing that work in the test runner CLI.
- The existing modules generally work by piping the output of Node into another process. It would be nice to be able to run something like
node --test --test-reporter=my-reporter
and have it just work.