Babel/Mocha:已在全球安装Mocha,但未定义describe() [英] Babel/Mocha: Mocha installed globally but describe() is not defined

查看:71
本文介绍了Babel/Mocha:已在全球安装Mocha,但未定义describe()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行测试,但出现此错误:

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已在项目的全局和本地安装.我不确定我是否正确,但这是我的测试脚本:

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.

推荐答案

package.json中尝试此配置:

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

--require选项用于包括should之类的模块,但不包括单元测试文件. 有关此选项的更多信息.

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

这篇关于Babel/Mocha:已在全球安装Mocha,但未定义describe()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆