This is a follow-up to my previous question.
Suppose I am writing the calculate.js
source file with a calculate
function to use it in my client-side code:
function calculate(num) { return num * 2; }
Now I would like to test it.
I am using nodeunit
as described in this article and export the calculate
function (so that tests can invoke it).
function calculate(num) { return num * 2; } exports.calculate = calculate // Node.js stuff. It won't run in a browser!
The nodeunit
tests run OK, but I cannot use calculate.js
in my web application any longer since it uses exports
.
Now it looks like a catch. Can I fix this problem?
Use a non-Node.js testing framework like jasminebdd or jstestdriver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With