avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.74k stars 1.41k forks source link

feature request: reporter customization #3163

Closed gibson042 closed 1 year ago

gibson042 commented 1 year ago

Related to #3160, my CI setup would greatly benefit from having TAP output include parseable test duration (e.g., as requested by https://github.com/TestAnything/Specification/issues/16 ). This is not part of the built-in TapReporter (and appropriately so!), but there's also no way that I can see to apply customization here.

Would you be willing to add a configuration option for this, e.g. --custom-reporter=/path/to/my-custom-reporter.{js,cjs,mjs} and customReporter: class MyCustomReporter { … }? It would require committing to and documenting the API surface area, but AFAICT the { extensions: string[], projectDir: string, reportStream: Writable, stdStream: Writable, watching: boolean } reporter constructor argument shape is simple and seems to be stable, and projectDir at least is already established as such at https://github.com/avajs/ava/blob/main/docs/06-configuration.md#avaconfigjs .

novemberborn commented 1 year ago

I don't think our current event format is fit for purpose, stable or extensible. But that's what such reporters would be hooking into. See also https://github.com/avajs/ava/issues/2608 and https://github.com/avajs/ava/discussions/3004. The latter would probably be the most flexible approach.

gibson042 commented 1 year ago

@novemberborn What would you think about updating that internal format to conform with https://github.com/js-reporters/js-reporters?

novemberborn commented 1 year ago

That project looks abandoned… and at first glance, what AVA needs is an interchange format we'd emit to stdout so you can pipe to other tools. We wouldn't necessarily want to load third-party code into the main process.

gibson042 commented 1 year ago

Acknowledged. We'll continue local patching for our purposes until such an interface is available.