Skip to content

Loading…

tap callbacks and errors printing wrong stack #8

Closed
mcavage opened this Issue · 3 comments

2 participants

@mcavage

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
    t.end();
  });
});

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:   ~
    stack:   
      - /Users/mark/work/node-ldap/tst/fail.test.js:8:23
    unique:  0
  ...

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

Do it this way instead of using regexps: http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi

@isaacs
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.

@isaacs
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.