Uncaught errors will cause tape-run to exit successfully
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
i can reproduce, working on it
needs to be merged: https://github.com/substack/tap-finished/pull/6
published a temporary fix as 2.1.1, until tap-finished is fixed
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?
that should work:
let code;
reader
.pipe(tapeRun())
.on('results', results => {
process.exit(Number(!results.ok));
})
.pipe(tapSpec())
.pipe(process.stdout);
Thank!
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: