0

I am writing unit test cases for one of my node modules using mocha, chai, should and expect. Where some function signatures are like this -

module.exports.user = (logger, options) => {
 let db = options.db,
 smtp = options.smtp

 logger.info('The user name is '+smtp.username)
}

My question is how do I mock the options and logger parameter, since the options come from req.headers.options and logger comes from req.headers.options.logger I am putting the options and logger using a middleware in server file.

Jeet
  • 5,569
  • 8
  • 43
  • 75

1 Answers1

1

Use sinon.js to mock the object req.headers.options

You can start with this similary question

Troopers
  • 5,127
  • 1
  • 37
  • 64