Answer the question
In order to leave comments, you need to log in
How to properly test such constructs using Mocha, Chai, Sinon?
Hello dear community. I ask you to suggest/indicate/direct to the true path). Just started learning nodejs and trying to start writing tests. And almost immediately the question arose:
There is, let's say, such a design, simplified:
method1(arg1, arg2, callback);
method2(arg3, arg4, callback);
method3(arg5, callback) {
async.waterfall([
function(cb) {
method1(agr1, arg2, function(error, result1) {
if (error) return cb(error);
// ... smth code
cb(null, result1);
});
},
function(result1, cb) {
method2(agr3, arg4, function(error, result2) {
if (error) return cb(error);
// ... smth code
cb(null, result2);
});
}
], function(error, results) {
// ... smth code
});
});
Answer the question
In order to leave comments, you need to log in
If you do not call method1 and method2 from outside, then you should not cover them with tests, because even if they disappear, the external code will not know about it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question