使用 NodeUnit 的要点之一是编写新函数并经常对其进行测试。问题是,如果其中一个测试函数抛出错误(包括 JS 运行时错误),则错误不会显示给用户。这是最简单的测试用例:(注意 abcd 会导致运行时错误)
exports.all = {
  one: function( test ){
    test.done();
  },
  two: function( test ){
    as( function( err, res ){
      test.done();
    });
  },
}
function as( callback ){
  process.nextTick( function() {
    a = testMe();
    callback( null, a );
  });
}
function testMe(){
  a.b.c.d.e = 100;
  return 10;
}
但是,testMe() 可能是我正在开发的一个新功能。一个未初始化的变量,或者任何东西,都会沉默。