Testing within a javascript closure

前端 未结 3 1069
臣服心动
臣服心动 2020-12-31 06:26

Is it possible to unit test javascript functions that exist within a closure, so for example, given the following:

(function() {
  var a = function() {
    /         


        
3条回答
  •  说谎
    说谎 (楼主)
    2020-12-31 06:56

    Your anonymous function could take a parameter which would be undefined when not in test mode, and say this parameter would be an object, you could fill the object with a's without exposing a directly.

    Just my .02$

提交回复
热议问题