mocha ReferenceError: describe is not defined 问题解决

mocha 是nodejs 开发中比较常用的断言库,大家如果直接安装node 的启动方式会有如下的错误

  • 错误信息
    ReferenceError: describe is not defined
  • 解决方法
    应该使用mocha 启动测试,可选的方式,全局安装mocha 或者本地安装,使用npm script 启动,如下
    pacakge.json 配置
 
{
  "name": "zombie",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {},
  "scripts": {
    "start": "mocha app.js"
  },
  "devDependencies": {
    "mocha": "^7.1.0",
    "zombie": "^6.1.4"
  }
}

说明

以上是一个问题的记录,实际上是一个很简答的问题

参考资料

https://mochajs.org/#getting-started
https://github.com/mochajs/mocha
https://stackoverflow.com/questions/28400459/referenceerror-describe-is-not-defined-nodejs

猜你喜欢

转载自www.cnblogs.com/rongfengliang/p/12508739.html