gpt4 book ai didi

mocha - TypeError:严格模式函数或调用它们的参数对象上可能无法访问'caller','callee'和'arguments'属性

转载 作者:行者123 更新时间:2023-12-02 05:20:06 28 4
gpt4 key购买 nike

以下错误是什么意思,我该如何解决?

$ npm test

> location-autosuggest@3.0.0 test /Users/mishamoroshko/location-autosuggest
> mocha test --compilers js:babel/register



compareKeys()
should return -1
1) when first key is different


0 passing (301ms)
1 failing

1) compareKeys() should return -1 when first key is different:
TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
at Context.<anonymous> (compare-keys/compare-keys.test.js:3:16)

以下是相关部分:

比较键/compare-keys.test.js
1. 'use strict';
2.
3. import { expect } from 'chai';

package.json
"scripts": {
"test": "mocha test --compilers js:babel/register"
}

.babelrc
{
"stage": 0
}

mocha.opts

我没有。

版本
  • babel:5.5.1
  • Mocha :2.2.5
  • 柴:3.0.0
  • 最佳答案

    从ES5开始,在严格模式下,您不能使用callee等参数的某些属性。
    参见callee page上的MDN免责声明:

    ECMAScript(ES5)的第五版禁止使用arguments.callee()
    在严格模式下。通过以下两种方式避免使用arguments.callee()
    函数表达式名称或使用函数声明,其中
    函数必须自行调用。
    chai可以使用以下属性之一。

    关于mocha - TypeError:严格模式函数或调用它们的参数对象上可能无法访问'caller','callee'和'arguments'属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30663989/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com