I am writing unit tests for my Node.js application using Mocha. Since my tests include a lot of redundant assert.equal(someFunction(arg1, arg2, arg3...), expected);
, I thought of doing something like this:
var assertEqual = function(func, result)
{
assert.equal(func, result);
}
descrirbe('someFunction()', function() {
var arg1 = ...
var arg2 = ...
var func = someFunction;
assertEqual(func, result)
arg1 = ...
arg2 = ...
assertEqual(func, result);
}
This obviously does not work as func
will bind its argument when declared. Is there a way to pass those arguments by reference in Javascript instead, so that I can keep modifying them and just call func
instead of passing the arguments every time?