tape-testing / tape

tap-producing test harness for node and browsers
MIT License
5.77k stars 305 forks source link

Pipe into multiple reporters? #477

Closed screendriver closed 5 years ago

screendriver commented 5 years ago

Do you know if / how it is possible to pipe the TAP output into multiple reporters at once?

For example locally I want to pipe into tap-spec via

"test:unit": "tape 'test/unit/**/*.js' | tap-spec"

but in a CI system I want to use tap-xunit

"test:unit:ci": "tape 'test/unit/**/*.js' | tap-xunit > dist/test-results.xml"

I know I could do following

"test:unit:base": "tape 'test/unit/**/*.js'",
"test:unit": "yarn test:unit:base | tap-spec",
"test:unit:ci": "yarn test:unit:base | tap-xunit > dist/test-results.xml"

But then I have to run test:unit and test:unit:ci separately and that means the tests runs twice. Is there a way to define both reporters at once?

ljharb commented 5 years ago

That seems more like a unix question, and I don't think it's really possible. You might be able to direct the output to both stdout and stderr, and find something that can handle both streams, but that's beyond my unix expertise.

screendriver commented 5 years ago

Ok. I thought maybe one of you already has some experience with that and did that already :wink:

ljharb commented 5 years ago

Probably the simplest is to pipe the initial results into a file, and then you can cat the file twice.