Node.js unit-testing module has basic assertion assert.fail:
assert.fail(actual, expected, message, operator)
What does operator mean? I’m really new to unit-testing…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What the documentation says: The value of
operatoris being used to separate the values ofactualandexpectedwhen providing an error message. This is described in Node.js’ documentation for the assert module.But, if you try this in the interactive shell you see that the parameter seems to be ignored:
It all makes sense when you take a look at the implementation of the assert module, lines 101-109:
So, a better description might be that it is not used automatically in the message, but it can be used if you catch the exception and create an appropriate message yourself. In consequence, this parameter may be useful if you are going to create your own testing framework.
You can force Node.js to use that parameter if you omit the
messageparameter, e.g. by passingundefinedexplicitly: