Skip to content


tap callbacks and errors printing wrong stack #8

mcavage opened this Issue · 3 comments

2 participants


The tap runner will print the stack from the error, not the line in the test where the assertion failed:

var fs = require('fs');
var test = require('tap').test;

function ls(dir, callback) {
  fs.readdir(dir, function(err, files) {
    if (err)
      return callback(new Error(err.message));

    return callback(null, files);

test('assertion stack wrong', function(t) {
  ls('/_tmp', function(err, files) {
    t.ifError(err); // prints the error stack, not where this failed

bluesnoop:node-ldap mark$ node tst/fail.test.js 
# assertion stack wrong
not ok 1 ENOENT, No such file or directory
    type:    Error
    message: ENOENT, No such file or directory
    code:    ~
    errno:   ~
      - /Users/mark/work/node-ldap/tst/fail.test.js:8:23
    unique:  0

# tests 1
# fail  1
bluesnoop:node-ldap mark$ 
TAP in JavaScript member

Do it this way instead of using regexps:

TAP in JavaScript member

The issue is that throws and ifError print the stack from the error provided, not the stack of where it was found.

ifError should print both stacks.

TAP in JavaScript member

Fixed in 1.0

@isaacs isaacs closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.