@@ -180,6 +180,88 @@ Like `test(name, cb)` except if you use `.only` this is the only test case
180180that will run for the entire process, all other test cases using tape will
181181be ignored
182182
183+ ## var stream = test.createStream(opts)
184+
185+ Create a stream of output, bypassing the default output stream that writes
186+ messages to ` console.log() ` . By default ` stream ` will be a text stream of TAP
187+ output, but you can get an object stream instead by setting ` opts.objectMode ` to
188+ ` true ` .
189+
190+ ### tap stream reporter
191+
192+ You can create your own custom test reporter using this ` createStream() ` api:
193+
194+ ``` js
195+ var test = require (' tape' );
196+ var path = require (' path' );
197+
198+ test .createStream ().pipe (process .stdout );
199+
200+ process .argv .slice (2 ).forEach (function (file ) {
201+ require (path .resolve (file));
202+ });
203+ ```
204+
205+ You could substitute ` process.stdout ` for whatever other output stream you want,
206+ like a network connection or a file.
207+
208+ Pass in test files to run as arguments:
209+
210+ ```
211+ $ node tap.js test/x.js test/y.js
212+ TAP version 13
213+ # (anonymous)
214+ not ok 1 should be equal
215+ ---
216+ operator: equal
217+ expected: "boop"
218+ actual: "beep"
219+ ...
220+ # (anonymous)
221+ ok 2 should be equal
222+ ok 3 (unnamed assert)
223+ # wheee
224+ ok 4 (unnamed assert)
225+
226+ 1..4
227+ # tests 4
228+ # pass 3
229+ # fail 1
230+ ```
231+
232+ ### object stream reporter
233+
234+ Here's how you can render an object stream instead of TAP:
235+
236+ ``` js
237+ var test = require (' tape' );
238+ var path = require (' path' );
239+
240+ test .createStream ({ objectMode: true }).on (' data' , function (row ) {
241+ console .log (JSON .stringify (row))
242+ });
243+
244+ process .argv .slice (2 ).forEach (function (file ) {
245+ require (path .resolve (file));
246+ });
247+ ```
248+
249+ The output for this runner is:
250+
251+ ```
252+ $ node object.js test/x.js test/y.js
253+ {"type":"test","name":"(anonymous)","id":0}
254+ {"id":0,"ok":false,"name":"should be equal","operator":"equal","actual":"beep","expected":"boop","error":{},"test":0,"type":"assert"}
255+ {"type":"end","test":0}
256+ {"type":"test","name":"(anonymous)","id":1}
257+ {"id":0,"ok":true,"name":"should be equal","operator":"equal","actual":2,"expected":2,"test":1,"type":"assert"}
258+ {"id":1,"ok":true,"name":"(unnamed assert)","operator":"ok","actual":true,"expected":true,"test":1,"type":"assert"}
259+ {"type":"end","test":1}
260+ {"type":"test","name":"wheee","id":2}
261+ {"id":0,"ok":true,"name":"(unnamed assert)","operator":"ok","actual":true,"expected":true,"test":2,"type":"assert"}
262+ {"type":"end","test":2}
263+ ```
264+
183265# install
184266
185267With [ npm] ( https://npmjs.org ) do:
0 commit comments