How can you test the behaviour of a module when an fs
module function throws an error? I have this code:
fs.stat('/Users/' + username.sync() + '/Library/LaunchAgents/' + key + '.plist', function(error, stat) {
if (!error) {
callback(null, true);
} else if (error.code == 'ENOENT') {
callback(null, false);
} else {
callback(error, null);
}
return;
});
But currently, the else
path is never run during tests. What would be the best-practise way to cover this line?
Thanks
Aucun commentaire:
Enregistrer un commentaire