Closed RichardLitt closed 7 years ago
Sometimes I'll put all of the workhorse functions in their own "inner modules" in lib/
, and then have a very simple main.js
that's something like
var workhorse = require('./lib/workhorse')
module.exports = workhorse
Then you can have your unit tests reference those inner modules, but still only export a single function to downstream.
I've seen that before! Not sure why I didn't notice that that was what it was doing. This makes a lot of sense. Thank you, @noffle.
And thanks for helping me out with these! Nominally, these are for me to answer, but you seem to be particularly adroit at answering them before I have to. 😄
No problem @RichardLitt. :ok_hand: I must've set this repo to "Watched" a while ago, so I get emails for these, and sometimes they're super familiar questions.
Well I hope you don't mind if I keep doing this! You don't have to answer them all. :D
Haha, I'll keep answering as long as I have time and have something to say.
I want to export a single function for a Node package I am writing, so that you don't need to specify a method to use it. However, I want to run unit tests for all of the little functions I am writing around that function, because that's how you do TDD. So, how do I export those little functions, while also exporting the main function?
CF https://github.com/RichardLitt/gh-description/blob/master/index.js