Babel/Mocha: Mocha installed globally but describe

2019-08-01 00:29发布

I'm trying to run a test and I'm getting this error:

/dev/tests/counters.spec.js:12
describe('Work damn you!', function () {
^

ReferenceError: describe is not defined

Mocha is installed both globally and locally to the project. I'm not sure if I've got it right, but this is my test script:

"test": "mocha --compilers js:babel-register --require dev/tests/counters.spec.js"

Am I going anything that's plainly wrong? Any help would be welcome.

1条回答
混吃等死
2楼-- · 2019-08-01 00:59

Try this configuration in package.json:

{
  // ...
  "test": "mocha dev/tests/counters.spec.js --compilers js:babel-register"
  // ...
}

The --require option is used to include modules like should, but not the unit test files. See more about this option.

查看更多
登录 后发表回答