Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught errors will cause tape-run to exit successfully #27

Open
rstacruz opened this issue Jan 9, 2016 · 7 comments
Open

Uncaught errors will cause tape-run to exit successfully #27

rstacruz opened this issue Jan 9, 2016 · 7 comments
Labels

Comments

@rstacruz
Copy link

rstacruz commented Jan 9, 2016

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
@juliangruber
Copy link
Collaborator

i can reproduce, working on it

@juliangruber
Copy link
Collaborator

@juliangruber
Copy link
Collaborator

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

@unional
Copy link

unional commented Apr 9, 2016

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?

@juliangruber
Copy link
Collaborator

that should work:

let code;

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

@unional
Copy link

unional commented Apr 9, 2016

Thank!

@unional
Copy link

unional commented Apr 10, 2016

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(). 😄

@fregante fregante added the bug label Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants