Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them

What does the following error mean, and how should I fix it?

$ npm test

> [email protected] 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)

Here are the relevant parts:

compare-keys/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

I don't have one.

Versions

  • babel: 5.5.1
  • mocha: 2.2.5
  • chai: 3.0.0
like image 285
Misha Moroshko Avatar asked Nov 17 '25 08:11

Misha Moroshko


1 Answers

Since ES5, in strict mode, you cannot use some properties of arguments like callee, etc. See for example the disclaimer on MDN on the callee page :

The 5th edition of ECMAScript (ES5) forbids use of arguments.callee() in strict mode. Avoid using arguments.callee() by either giving function expressions a name or use a function declaration where a function must call itself.

chai may use one of these properties.

like image 52
krampstudio Avatar answered Nov 20 '25 04:11

krampstudio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!