I'm writing unit tests for io.js, because I'm about to change it and
changing code without unit tests makes me nervous.  Some of the
internal functions are difficult to test because they are hidden in a
closure.  I like hiding implementation details in a closure, but I
like testing more.  I'm thinking about modifying the code so the style
is more in the style of js classes, such as person.js.

As an example of the kind of function that is giving me trouble,
consider processResponse.  It's had bugs in the past, it will in the
future, but the interface is clean enough that it *should* be
testable.  I can't figure out how to test it without pulling it out of
the closure.

Are there better alternatives?

Cheers,
Brian

Reply via email to