diff --git a/index.js b/index.js index fd85165..e6c24fe 100644 --- a/index.js +++ b/index.js @@ -24,9 +24,13 @@ if (command.examples) { if (command.browser) { nodeRequire('./lib/cli').launch(); nodeRequire('./lib/browser')([require.main.filename], command); -} else if ((isNode || isProvaFrame) && !command.tap) { - view = isNode ? nodeRequire('./lib/node-reporter') : require('./lib/browser-reporter'); +} else if (isNode && !command.tap) { + view = nodeRequire('./lib/node-reporter'); tape.createStream({ objectMode: true }).pipe(refine()).pipe(view()); +} else if (isProvaFrame) { + tape = tape.createHarness(); + view = require('./lib/browser-reporter'); + tape.createStream({ objectMode: true }).pipe(refine()).pipe(view(tape._results._stream)); } if (isNode) { diff --git a/lib/browser-reporter.js b/lib/browser-reporter.js index 46ee621..523ebd6 100644 --- a/lib/browser-reporter.js +++ b/lib/browser-reporter.js @@ -7,10 +7,14 @@ var started = false; var failed = 0; var passed = 0; var excludeFromStack = ['prova']; +var rawTAPBuffer = []; module.exports = reporter; -function reporter () { +function reporter (rawTapStream) { + rawTapStream.on('data', function(c) { + rawTAPBuffer.push(c); + }); return through(each, end); } @@ -62,10 +66,12 @@ function fail (row) { } function end () { + post('end', { failed: failed, passed: passed, - tests: tests + tests: tests, + rawTAPOutput: rawTAPBuffer.join('') }); this.queue && this.queue(null); diff --git a/lib/browser.js b/lib/browser.js index 5dba662..88319d6 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -99,7 +99,7 @@ function start (files, command) { msg = JSON.parse(msg.data); if (msg.result) { - outputResult(msg); + outputResult(msg, command.tap); if (command.quit) process.exit(msg.result.failed); return; } @@ -247,11 +247,16 @@ function outputError (msg) { })); } -function outputResult (msg) { - var failed = msg.result.failed; - var template = failed ? failTemplate : passTemplate; +function outputResult (msg, outputRawTAP) { - console.log(formatText(template, msg.result) + ' ' + formatUserAgent(msg.userAgent)); + if (outputRawTAP) { + console.log(msg.result.rawTAPOutput); + } else { + var failed = msg.result.failed; + var template = failed ? failTemplate : passTemplate; + + console.log(formatText(template, msg.result) + ' ' + formatUserAgent(msg.userAgent)); + } } function formatUserAgent (rawUserAgent) { diff --git a/package.json b/package.json index bd428c5..3c9df3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prova", - "version": "1.14.3", + "version": "1.15.0", "description": "Test runner based on Tape and Browserify", "main": "index.js", "bin": {