jeudi 28 janvier 2016

What is the best way to write mocha unit tests when Node.js required modules need to be stubbed/mocked?

var config = require('../config/config');
var dynasty = require('dynasty')(config);

dynasty.list('name').then(function(resp) {
    console.log(resp);
});

I've tried using libraries like Sinon, proxyquire and mockery but have been unsuccessful.

Also what does require('dynasty')(config) mean? I know it's passing in the values stored in the variable config, but is there any other way to achieve this, or to pass this value while using one of the testing libraries?

Aucun commentaire:

Enregistrer un commentaire