tape-run icon indicating copy to clipboard operation
tape-run copied to clipboard

Uncaught errors will cause tape-run to exit successfully

Open rstacruz opened this issue 9 years ago • 7 comments

Consider this test:

var test = require('tape')

test('...', function (t) {
  throw new Error('hmm')
  t.end()
})

Running this through tape-run like so will cause it to succeed.

$ browserify test.js | tape-run
TAP version 13
# ...
Error: hmm
    at Test.<anonymous> (http://localhost:51270/bundle.js:11:9)
    at Test.bound [as _cb] (http://localhost:51270/bundle.js:5237:32)
    at Test.run (http://localhost:51270/bundle.js:5253:10)
    at Test.bound [as run] (http://localhost:51270/bundle.js:5237:32)
    at next (http://localhost:51270/bundle.js:5055:15)
    at Item.run (http://localhost:51270/bundle.js:2566:14)
    at drainQueue (http://localhost:51270/bundle.js:2536:42)

$ echo $?
0

rstacruz avatar Jan 09 '16 17:01 rstacruz

i can reproduce, working on it

juliangruber avatar Jan 09 '16 17:01 juliangruber

needs to be merged: https://github.com/substack/tap-finished/pull/6

juliangruber avatar Jan 09 '16 19:01 juliangruber

published a temporary fix as 2.1.1, until tap-finished is fixed

juliangruber avatar Jan 09 '16 19:01 juliangruber

Related to this. I am running npm test, where:

// package.json
{
  "scripts": {
    "test": "node test.js <test file globs>"
  }
}
// test.js
   ...

  reader
  .pipe(tapeRun())
  .pipe(tapSpec())
  .pipe(process.stdout);

and the return is 0.

What should I do to get it to return error?

unional avatar Apr 09 '16 01:04 unional

that should work:

let code;

reader
.pipe(tapeRun())
.on('results', results => {
  process.exit(Number(!results.ok));
})
.pipe(tapSpec())
.pipe(process.stdout);

juliangruber avatar Apr 09 '16 20:04 juliangruber

Thank!

unional avatar Apr 09 '16 20:04 unional

I changed it a bit to:

    reader
      .pipe(run())
      .on('results', results => {
        if (!results.ok) {
          process.exit(1);
        }
      })
      .pipe(tapSpec())
      .pipe(process.stdout);

so that the summary will sent to tapSpec(). :smile:

unional avatar Apr 10 '16 06:04 unional