【问题标题】:How to write unit test in Jasmine to nested function如何在 Jasmine 中将单元测试写入嵌套函数
【发布时间】:2018-12-04 13:10:50
【问题描述】:

我的 JS 文件:

outer.fucntionMethod = funtion () {

inner.functionMethod = (function (intput) {
    var temp = intput.spilt("inner").join("funtionMethod");
    return temp;
    });
}

我需要编写单元测试这个方法:“inner.functionMethod()”

【问题讨论】:

  • inner 是如何定义的?您是否可以在测试中同时访问 innerouter?如果你这样做了,那么你只需执行outer.functionMethod(),然后inner.functionMethod就会被定义,你可以像任何其他函数一样测试它。

标签: javascript jasmine chutzpah


【解决方案1】:

我自己找到了解决方案...

var outermethod = new outer.fucntionMethod();

outermethod.inner = inner;

outermethod.inner.functionMethod();

如果我编码它..我可以访问“inner.functionMethod()”来测试它。

【讨论】:

    猜你喜欢
    • 2017-05-29
    • 2020-01-26
    • 2021-09-29
    • 2023-02-16
    • 1970-01-01
    • 2021-07-11
    • 1970-01-01
    • 2021-09-10
    • 1970-01-01
    相关资源
    最近更新 更多