我想编写一个辅助函数,它要么断言作为参数给出的测试函数,要么默认调用 assert.equal。
运行下面的代码时,我收到以下错误:Expected 1 assertions, 0 ran
var assert = require('nodeunit').assert;
var interpretTest = function(expression, expected, testFunction) {
testFunction = testFunction || assert.equal;
return function(test) {
test.expect(1);
testFunction(expression, expected);
test.done();
};
};
exports.testEqual = interpretTest([8, 6], [8, 6], assert.deepEqual);
删除 test.expect(1) 但有 0 个断言时测试通过。