Testing 如何在Nodeunit中添加自定义断言

Testing 如何在Nodeunit中添加自定义断言,testing,node.js,nodeunit,Testing,Node.js,Nodeunit,有没有一种方法可以向传递给每个测试的NodeUnittest对象添加自定义断言 我想做一些类似的事情: var Test = require('nodeunit').Test; Test.prototype.customAssertion = function(obj) { test.same(obj.foo, 'bar'); test.same(obj.bar, 'baz'); } exports.test = function(test) { test.customAsser

有没有一种方法可以向传递给每个测试的NodeUnit
test
对象添加自定义断言

我想做一些类似的事情:

var Test = require('nodeunit').Test;

Test.prototype.customAssertion = function(obj) {
  test.same(obj.foo, 'bar');
  test.same(obj.bar, 'baz');
}

exports.test = function(test) {
  test.customAssertion(obj);

  test.done();
}
var assert = require('nodeunit').assert;
var testCase = require('nodeunit').testCase;

assert.isVowel = function(letter, message) {
    var vowels = [ 'a', 'e', 'i', 'o', 'u' ];

    if (vowels.indexOf(letter) == -1) {
        assert.fail(letter, vowels.toString(), message, 'is not in');
    }
};

exports["Vowel"] = testCase({
    "e should be a vowel": function(test) {
        test.isVowel("e", 'It should be a vowel.');
        test.done();
    }
});