4

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

$ 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)

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
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746

2 Answers2

1

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.

krampstudio
  • 3,519
  • 2
  • 43
  • 63
-2

I updated babel to 5.5.3 and it fixed the issue.

Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746