【问题标题】:Function.prototype.apply was called on #<Object>, which is a object and not a functionFunction.prototype.apply 在#<Object> 上被调用,它是一个对象而不是一个函数
【发布时间】:2019-02-07 10:14:31
【问题描述】:

我正在使用 node-js,我在一个名为 utils.js 的文件中有这行代码:

const spartial = (func, ...args) => (...rest) => func(...args, ...rest);

文件App.js 包含一个名为App 的类,该类使用utils.js 中的spartial 函数。

我已经使用 ava 库编写了一个单元测试,该库测试了 App.js,当我运行测试时,我收到了这个错误:

Function.prototype.apply was called on #<Object>, which is a object and not a function

下面的代码行以红色突出显示...

 1: const spartial = (func, ...args) => (...rest) => func(...args, ...rest);

有谁知道这里发生了什么以及如何解决这个问题?我不确定是否是单元测试库导致了问题,但是当我运行 node utils.js 时,我没有收到任何错误。

【问题讨论】:

    标签: javascript node.js unit-testing ava


    【解决方案1】:

    这完全是因为我以错误的顺序调用了spartial 函数。我不知道我看了一个小时后怎么没有看到这个。

    【讨论】:

      猜你喜欢
      • 2021-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-12
      • 1970-01-01
      • 1970-01-01
      • 2015-11-26
      • 1970-01-01
      相关资源
      最近更新 更多